Preserving metadata in resized image using PHP -


i have php script scans directory images, resizes finds , saves them overwriting originals. works except fact strips metadata image.

i found toolkit can manipulate metadata including extracting , writing images. on this page explains how (at bottom of page).

so added code having problems - not write metadata resized image. missing can't seem figure out (probably lack of coding skill) , wondered if can spot error , suggest correction.

here relevant part of code:

this used confirm images found , contain metadata - printing in html format

echo " $file <br> " ;         $filename = $file;         $exif_data = get_exif_jpeg( $filename );         echo interpret_exif_to_html( get_exif_jpeg( $filename ), $filename ); 

here code resizes image , saves it, , should write meatada - doesn't

$new_image = imagecreatetruecolor($new_width,$new_height);         imagecopyresized($new_image, $tmp_image,0,0,0,0, $new_width, $new_height, $width, $height);         //grab new image         imagejpeg($new_image, $target_path);         $image_buffer = ob_get_contents();         imagedestroy($new_image);         imagedestroy($tmp_image);         echo " $file resized $new_width x $new_height <br> \n";         echo str_pad('',4096)."\n";         $jpeg_header_data = put_exif_jpeg( $exif_data, $jpeg_header_data );         put_jpeg_header_data( $filename, $filename, $jpeg_header_data );          ob_flush();         flush(); 

is case of having put rewrite code in wrong place - or else?

thanks suggestions.

i think problem here :

put_jpeg_header_data( $filename, $filename, $jpeg_header_data );

changed

put_jpeg_header_data( $filename, $new/output_image, $jpeg_header_data );

hope works!


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -