Skip to content Skip to sidebar Skip to footer

Image Resize Using Php Image Magician

i am trying to display an uploaded image along with text watermark in a different size using php-image-magician without saving the image. here are the codes :

Solution 1:

I never used php-image-magician, so the following may very well be false information.

From what I see:

$magicianObj = new imageLib($_FILES["image"]["tmp_name"]);

Internally, imageLib calls openImage which in turn does the following: 1) it checks if the file actually exists 2) it checks the extension and uses the correct imagecreatefrom___ function.

This is where your problems start. When you upload files to your webserver, they get saved under a temporary filename (in your example, "php9E3D.tmp"). This extension (.tmp) is not in the list of allowed extensions for php-image-magician (.jpg, .jpeg, .gif, .png, .bmp, .psd). As such, the internal image variable gets set to false and the whole library won't work.

You have several options to tackle this issue:

1) Rewrite php-image-magician (specifically openImage), this however is not recommended.

2) Rename your uploaded file using move_uploaded_file, see Example #2 here.

3) Get rid of your dependency on php-image-magician and use PHPs internal functions (imagescale and friends, you're already creating an image resource to work with in your renderImage function)

Hope this helps.

Post a Comment for "Image Resize Using Php Image Magician"