I am trying to resize and crop an image on a php page. I either want to use gd lib or jcrop with FileReader(). Which would be a better wat to go. what are the pros/cons ?
jcrop
and FileReader()
both are the frontend browser library or api,while
gb lib
is the php backend library.
I have to two solutions FYI.
jcrop
+FileReader()
for user crop the image,and then frontend get new the cropped image's data like {x:50,y:100,width:100,height:200}
relative to original image,which will be posted to backend for php process gb lib
( imagecrop
function).pros: balance both frontend and backend performance. cons: code looks more complicated
jcrop
+FileReader()
for user crop the image,and them frontend get new the cropped image's base64 string,then post to the server.Server no need to call gb lib
to crop.Just decode base64 image and save it as file.pros: code looks more simple. cons: increase frontend pressure. Save bandwidth (no need to upload original image)
Finally,up to you to add more logic in frontend or backend.