PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, October 10, 2022

[FIXED] Which is the better way to manipulate an image, using gd lib or using the FileReader() with Jcrop?

 October 10, 2022     gd, html, jcrop, php     No comments   

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.

  1. 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

  1. 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 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.



Answered By - Adam Liu
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing