Вот щас подтачиваю загруз цент под себя, ну м озадачился таким вопросом, Как вывести с jar файла иконку c помощю php ?
Обясните поподробней, или дайле ссылку на нужный ресурс...
Любителям посылать в гугл - смотрел и ненашел.
Бывалый, сравнивай расширения файлов:
$ex = pathinfo("путь до файла");
$ext = strtolower($ex['extension']);
if($ext == "jar") { $icon = "картинка к иконке"; }
Для таких вопросов топ тема есть.
$zip = new ZipArchive;
if ($zip->open('путь до файла') === TRUE) {
if($manifest = $zip->getFromName('META-INF/MANIFEST.MF')){
if (strpos($manifest, 'MIDlet-Icon: ') !== FALSE){
$jad = explode('MIDlet-Icon: ',$manifest);
$icon = str_replace("\n",' ', $jad[1]);
$icon = str_replace("\r",' ', $icon);
$icon = strtok($icon,' ');
$icon = preg_replace('#^/#', NULL, $icon);
}
else $icon='icon.png';
}else exit;
if($image = $zip->getFromName($icon)){
$image = imagecreatefromstring($image);
$width=imagesx($image);
$height=imagesy($image);
$x_ratio=16/$width;
$y_ratio=16/$height;
if(($width<=10)&&($height<=10)){
$tn_width=$width;
$tn_height=$height;
}elseif(($x_ratio*$height)<16){
$tn_height=ceil($x_ratio*$height);
$tn_width=16;
}else{
$tn_width=ceil($y_ratio*$width);
$tn_height=16;
}
$dst=ImageCreate($tn_width,$tn_height);
imagecopyresampled($dst, $image, 0, 0, 0, 0, $tn_width,$tn_height,$width,$height);
$image = $dst;
}else{
//эта иконка будеет, если в архиве нет иконки
$image = imagecreatefrompng(ROOT.'/_images/ico.png');
}
header('Content-type: image/png');
ImagePng($image);
ImageDestroy($image);
$zip->close();
}
из MobileCMS кусок, переделайте под себя если нужно
/**
* Получение иконки java приложения
*/
public static function get_icon($jar_path, $icon_path = false) {
if(!class_exists('PclZip')) a_import('libraries/pclzip.lib');
if(!file_exists($jar_path)) a_error('JAR файл не найден!');
$zip = new PclZip($jar_path);
# Получем манифест
$manifest_arr = $zip->extract(PCLZIP_OPT_BY_NAME, 'META-INF/MANIFEST.MF', PCLZIP_OPT_EXTRACT_AS_STRING);
if(!$manifest = $manifest_arr[0]['content']) a_error('Manifest не найден!');
# Получаем адрес иконки в архиве
$ex = explode("\n", $manifest);
foreach($ex as $str) {
if(strstr($str, 'MIDlet-1:')) {
$_ex = explode(',', $str);
$icon = trim($_ex[1]);
}
}
if(empty($icon)) return false;
# Если иконка есть в манифесте, извлекаем ее
$icon_arr = $zip->extract(PCLZIP_OPT_BY_NAME, $icon, PCLZIP_OPT_EXTRACT_AS_STRING);
if(!$icon_content = $icon_arr[0]['content']) return false;
if($icon_path) {
file_put_contents($icon_path, $icon_content);
return true;
}
else return $icon_content;
}