Is there anyway to remove the iptc tags from an image without recreating the image with GD? the examples on php.net doesn't work, and i cannot use external programs. Please help
If your server has Imagick you can use it: https://stackoverflow.com/questions/3614925/remove-exif-data-from-jpg-using-php
Have you tried xtempore comment in that link? It uses no external library. /** * Remove EXIF from a JPEG file. * @param string $old Path to original jpeg file (input). * @param string $new Path to new jpeg file (output). */ function removeExif($old, $new) { // Open the input file for binary reading $f1 = fopen($old, 'rb'); // Open the output file for binary writing $f2 = fopen($new, 'wb'); // Find EXIF marker while (($s = fread($f1, 2))) { $word = unpack('ni', $s)['i']; if ($word == 0xFFE1) { // Read length (includes the word used for the length) $s = fread($f1, 2); $len = unpack('ni', $s)['i']; // Skip the EXIF info fread($f1, $len - 2); break; } else { fwrite($f2, $s, 2); } } // Write the rest of the file while (($s = fread($f1, 4096))) { fwrite($f2, $s, strlen($s)); } fclose($f1); fclose($f2); } PHP:
Yes and that didn't work as it tries to remove EXIF information, not the IPTC data wich i use and want to remove.
As the answer in this: https://stackoverflow.com/questions/5833026/extract-iptc-information-from-jpeg-using-javascript 0xFFED seems to be IPTC marker. Perhaps you could try that replacing EXIF marker (0xFFE1) in the above function to see if that works?
Thank you so much, this worked like a charm! It removed 200 bytes from an image, and that part contained the IPTC data! Again, thanks, you made my day!! -BTW i couldn't set your answer as best answer as it contained two posts ;-)