Ich verwende jQuery-File-Upload Skripte. Das Paket enthält auch ein PHP-Skript, um die Dateien zu bearbeiten und Thumbnails zu erstellen. Alles funktioniert gut, aber ich muss statische Thumbnails erstellen, falls Benutzer animierte Gif-Dateien hochladen.Imagemagick: kann keine statische Miniatur von GIF-Animation
Unten ist die Funktion, die Miniaturansichten erstellt.
Ich habe alles für "Behandle animierte GIFs" auskommentiert, da ich animierte Thumbnails aus animierten Gifs nicht möchte.
und fügte eine Linie:
mail('[email protected]', 'file_path', "$file_path");
Beim Hochladen, erhalte ich E-Mails mit Dateipfad wie: /var/www/images/image.gif
Dann habe ich die folgende Zeile Thumbnails aus dem ersten Frame zu machen
$file_path = $file_path[0];
mail('[email protected]', 'file_path', "$file_path");
Jetzt bekomme ich leere E-Mails und Miniaturansichten werden nicht erstellt. Daher existiert die Variable $ file_path [0] nicht. Warum?
Wie kann ich statische Miniaturbilder aus animierten GIFs erstellen?
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;
}