Jump to content
DareToProvoke

[Admin Panel FIX] Proper manual image resize with scaling | AdminImageResize.php + cropper/loader.js + images.inc.php

Recommended Posts

didn't know where to put it so here it is...


Goal:

enable full functionality of image crop provided by http://deepliquid.com/content/Jcrop.html used in PrestaShop admin panel.


Required changes:

- upload of missing js/css/gif files from Jcrop plug-in available from Jcrop website download to /js/cropper/ folder (check your firebug NET tab to see which files are missing)

- changes in /[admin folder]/tabs/AdminImageResize.php (see attachment #1)

- changes in /images.inc.php (see attachment #2)

- changes in /js/cropper/loader.js (see attachment #3)


What was changed

- altered all the files to make full use of both the Jcrop and imagecopyresampled PHP GD function used to resize images


Result:

- fully functional automatic crop working as it used to

+ fully functional manual crop with scaling with preserved ratio - can both scale down the image if selected area is bigger then the output area or scale up if selected area is smaller then the output area (watch out for quality if doing so!)



Warning!

- because of the nature of the plugin to 'save' the cropped coords/dimensions you have to click the cropped area as sliding doesn't update the values used by function

if anybody would have had any troubles applying this patch feel free to poke me for help :)


Hope more people will find it useful!


best regards and keep up the great job

loader.js

images.inc.php

AdminImageResize.php

Share this post


Link to post
Share on other sites

This didn't work for me. I kept getting the following errors:

[17-Mar-2009 18:12:32] PHP Warning: imagecolorallocate(): supplied argument is not a val
id Image resource in images.inc.php on line 215
[17-Mar-2009 18:12:32] PHP Warning: imagecopyresampled(): supplied argument is not a val
id Image resource in images.inc.php on line 216
[17-Mar-2009 18:12:32] PHP Warning: imagecolortransparent(): supplied argument is not a
valid Image resource in images.inc.php on line 217
[17-Mar-2009 18:12:32] PHP Warning: imagejpeg(): supplied argument is not a valid Image
resource in images.inc.php on line 261
[17-Mar-2009 18:12:32] PHP Warning: imagedestroy(): supplied argument is not a valid Ima
ge resource in images.inc.php on line 264

any idea what we're doing wrong here?

Share this post


Link to post
Share on other sites

hey daretoprovoke,

thanks for the Jcrop patching. i tried it out and it works, but i'd like to know how to remove proportional cropping? it seems like most javascript demos demonstrating live cropping usually leaves the proportion-lock off.

reason being: our product is much much wider than it is tall. 127x x 2388px is the ideal size of the image we need to create as a product image for our scroller idea on the front page.

(sorry to nag, i had sent a PM earlier)

thanks again!
alvin

img attached.

Share this post


Link to post
Share on other sites

Has anyone gotten this to work with the most recent version of Prestashop - I just get "1 error

an error occurred while copying image"

Would love to get this working

Share this post


Link to post
Share on other sites

this will be a time saver for the shop owner if anyone could pick it up and modularize it.

Share this post


Link to post
Share on other sites

I just needed the created thumbs to vary in size and not always be the size marked in setup
because some pictures are horizontal and some vertical and that would mess up the design because of the
extra fill... (because I want to use quite large images...) Now it automatically uses the bigger limit and other
edge of the image is what it needs to be in order to preserve proportions.

Anyways I changed these from images.inc.php which is located at root after line 150:
$borderWidth = 0;
$borderHeight = 0;
$destImage = imagecreatetruecolor($nextWidth, $nextHeight);
// $white = imagecolorallocate($destImage, 255, 255, 255);
// imagefill($destImage, 0, 0, $white); //prevent filling

So the last two lines are just commented out.. You can just delete if you want to..

Or if you just want the fill in the images be same color as your bg just change the values in $white.. Those are just RGB values.

-NRJ

Share this post


Link to post
Share on other sites

I don't get this.. Seems like Prestashop (at least versjon 1.2.5 and 1.3.1 uses Prototype and Scriptalicious for the cropping, where does jcrop (which is a Jquery-plugin in?)

For what its worth, Prestashop 1.3.1 seems to be missing the following files:
/js/cropper/effects.js
/js/cropper/controls.js
/js/cropper/slider.js

which are all part of scriptalicious :(

Share this post


Link to post
Share on other sites

so what should I do to make cropper work correctly with scaling in PS 1.3 version?

Share this post


Link to post
Share on other sites

Someone could make it work?
the error is “1 error an error occurred while copying image”

I think the solution to this problem can help us very much all

Thanks!

Share this post


Link to post
Share on other sites

Hello,

 

Sorry but I can not download the loader.js, can you reupload it? tks.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More