Jump to content

save image after jrcop


exhaler

Recommended Posts

hi all,

 

i'm trying to save an image after cropping it using jcrop (jquery plugin).

i'm currently using a script i found on the internet called ImageManipulation.php (attached).

its working fine, but i get a black image if i crop a gif, or png images (works great for jpg images).

 

$objImage = new ImageManipulation("../products/" . $_SESSION['image']); 
if ($objImage->imageok) {
    // get x, y, w, h from hidden inputs that are update by jcrop
    $objImage->setCrop($_POST['x'], $_POST['y'], $_POST['w'], $_POST['h']);
    $objImage->resize(150);
    $objImage->save("../products/" . $_SESSION['image']);
}

 

how can i fix this?? if you have a better way of using php with jcrop to save cropped images please share it :)

thanks for the help

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/231302-save-image-after-jrcop/
Share on other sites

From - http://deepliquid.com/content/Jcrop_Implementation_Theory.html

 

Obviously this script has some limitations. First of all, it only works with jpeg images, while the gd library functions support many common file formats.

 

It appears they have yet to implement coding for other formats.

I think litebearer might have misinterpreted that comment.  It only referred to some sample gd code.  There is no problem doing .gif or png files with the library you are using as far as I can see.  It supports jpg, gif, bmp and png.

 

I really don't know what the issue is.  What does it say when you run phpinfo() in the gd section?

if i upload a gif or png image i can use jcrop to select the area i want from that image. however, after i click on the crop button and send the x, y, w, h to ImageManipulation.php i get a black image.

 

i also ran a test in wordpress, uploaded a gif image selected a crop area using jcrop then clicked on the crop button, the result was a jpg cropped image and not a gif image.

 

how can i change a gif/png image to a jpg one?

sorry for the late reply had to come home to get the phpinfo:

GD Support 		enabled
GD Version 		bundled (2.0.34 compatible)
FreeType Support 	enabled
FreeType Linkage 	with freetype
FreeType Version 	2.4.3
GIF Read Support 	enabled
GIF Create Support 	enabled
JPEG Support 		enabled
libJPEG Version 	6b
PNG Support 		enabled
libPNG Version 		1.2.44
WBMP Support 	enabled
XBM Support 		enabled
gd.jpeg_ignore_warning	0	0 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.