views:

49

answers:

1

Hi. I use this class to crop, resize my image: http://www.phpclasses.org/package/4268-PHP-Resize-crop-rotate-flip-flop-and-grey-images.html

It uses GD. The problem is that I for example do this:

$img = new ImageTransform;
$img->view('resize', 'foo.jpg', '500x400', true); // true argument is $cache = true

Now I can just point

<img src="that_script.php" alt="" />
and it will show that image resized. But it doesn't if all my files are UTF-8! Only if they ALL are ANSI encoded. The image simply won't display if some or all files are encoded UTF-8. If i remove headers.. and just let it print all the things... I can see all funny characters... so it's printing something! But it just won't print the actual image with headers...

In the PHP documentation I found someone write this: http://no.php.net/manual/en/function.imagejpeg.php#96796

WARNING for those who use utf-8 scripts: Before going crazy like me for a whole day and digging around configuration files etc.

DIRECT BROWSER OUTPUT using image_jpeg worked only after i have saved my script in ANSI instead of utf-8

So it must be something wrong with PHP? I use PHP version: 5.3.2

Nobody at PHPClasses complains about something wrong, so I don't think it's the class. But something with PHP. The question is how can I make it work with UTF-8?

Thanks for help!

+2  A: 

Are you possibly saving the files as UTF8 BOM? That would likely screw up image output, since the BOM character is always output first. Try saving it as UTF8 No-BOM, that should be identical to ANSI files.

deceze
Notepad++ lets you convert/encode files to "utf8 without BOM"
Imre L
Basically, there can't be any characters before your <?php tag. If you save as UTF8 with BOM, the BOM goes before the <?php tag. Also watch out for MIME-type problems if you're serving an image file with a .php extension. I'd suggest adding a header() to send the image/jpeg MIME type.
Artelius
Thanks all! It works now :)!
slowkvant