Issue
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 ?
Solution
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 processgb lib
(imagecrop
function).
pros: balance both frontend and backend performance. cons: code looks more complicated
- only
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 callgb 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.
Answered By - Adam Liu Answer Checked By - Cary Denson (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.