jQuery-File-Upload komut dosyalarını kullanıyorum. Paket, dosyaları işlemek ve küçük resimler yapmak için bir php betiği içerir. Her şey iyi çalışıyor ancak kullanıcılar animasyonlu gif dosyalarını yüklüyorsa statik küçük resimler oluşturmam gerekiyor.Imagemagick: gif animasyonundan statik küçük resim yapamazsınız
Aşağıda, küçük resimler oluşturan işlev bulunur.
Animasyonlu giflerden animasyonlu küçük resimler istemediğimden, "Animasyonlu GIF'leri İşle:" için her şeyi açıkladım. gibi dosya yolu ile
yüklerkenmail('[email protected]', 'file_path', "$file_path");
, ben olsun e-postalar:
ve
bir çizgi eklenen ilk çerçeveden küçük yapmak için aşağıdaki satırı eklendi Sonra/var/www/images/image.gif
$file_path = $file_path[0];
mail('[email protected]', 'file_path', "$file_path");
Şimdi boş e-posta alıyorum ve küçük resimler oluşturulmuyor. Yani, $ file_path [0] değişkeni mevcut değil. Niye ya?
Animasyonlu giflerden nasıl statik küçük resimler oluşturabilirim?
protected function imagemagick_create_scaled_image($file_name, $version, $options) {
list($file_path, $new_file_path) =
$this->get_scaled_image_file_paths($file_name, $version);
$file_path = $file_path[0];
mail('[email protected]', 'file_path', "$file_path");
$resize = @$options['max_width']
.(empty($options['max_height']) ? '' : 'x'.$options['max_height']);
if (!$resize && empty($options['auto_orient'])) {
if ($file_path !== $new_file_path) {
return copy($file_path, $new_file_path);
}
return true;
}
$cmd = $this->options['convert_bin'];
if (!empty($this->options['convert_params'])) {
$cmd .= ' '.$this->options['convert_params'];
}
$cmd .= ' '.escapeshellarg($file_path);
if (!empty($options['auto_orient'])) {
$cmd .= ' -auto-orient';
}
//if ($resize) {
// Handle animated GIFs:
//$cmd .= ' -coalesce';
//if (empty($options['crop'])) {
//$cmd .= ' -resize '.escapeshellarg($resize.'>');
//} else {
//$cmd .= ' -resize '.escapeshellarg($resize.'^');
//$cmd .= ' -gravity center';
//$cmd .= ' -crop '.escapeshellarg($resize.'+0+0');
//}
// Make sure the page dimensions are correct (fixes offsets of animated GIFs):
//$cmd .= ' +repage';
//}
if (!empty($options['convert_params'])) {
$cmd .= ' '.$options['convert_params'];
}
$cmd .= ' '.escapeshellarg($new_file_path);
exec($cmd, $output, $error);
if ($error) {
error_log(implode('\n', $output));
return false;
}
return true;
}