Jump to content

Recommended Posts

I found a cool little script for resizing images on the fly with GD at the PHP[dot]net site:

http://www.php.net/manual/en/function.imagecopyresampled.php

 

See "Example #2 Resampling an image proportionally"

 

When I save that code as a self-contained file and modify the parameters to access an image, everything works perfectly. However, when I copy/paste the working code into another file in the exact same folder, the image renders as a bunch of garbled characters, like so:

 

�����JFIF��������� x{V��αq�wi5��{��f���Y�$�hmഅ|�0���|_�M�GOd������d����)m��l v��J��d��#,��3*����~Q���o_â~�>��.��MSG�[�vӬ,������9��n䶋h�1e�N� ��uO�

 

Has anyone else ever experienced this problem? If so, have you been able to fix it?

 

I have no idea why it'd be doing this, so any help would be greatly appreciated. Thanks.

Link to comment
https://forums.phpfreaks.com/topic/179133-solved-bizarre-gd-library-issue/
Share on other sites

copy/paste the working code into another file

 

Post your code in that other file showing what you are doing.

 

You cannot output a header or image data on a web page after you output any HTML or any other characters on the page.

That's likely my problem. Crud. The plan was to have several of these displaying in different spots all over the page. I guess plan B would be to upload images to the webserver that saves the images to various sizes & locations & then call them into the pages already sized using standard image tags.

 

Does that make sense?

Many thanks, PFMaBiSmAd.

 

I actually had a similar revelation as I was drifting off, so I jumped out of bed & fixed it all with passing values to the PHP image processing files with GET functions.

 

Image tags like <img src="img.php?filename=img/books/book1&width=210&height=500" /> work perfectly now.

 

Thanks for getting me straightened out.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.