Choosing between Imagemagick & GD for thumbnail creation

蹲街弑〆低调 提交于 2019-12-10 11:28:21

问题


I'm going to write a function for thumbnail creation.
I can use both Imagemagick & GD Library methods.
Which method creates better thumbnails and is faster and better for server (load, ...)?

Thanks


回答1:


$im = imagecreatefromjpeg('photo.jpg');

$ox = imagesx($im);
$oy = imagesy($im); 

$nx = 320;
$ny = 240;

$nm = imagecreatetruecolor($nx, $ny); 

imagecopyresized($nm,$im,0,0,0,0,$nx,$ny,$ox,$oy); 

imagejpeg($nm, 't_photo.jpg');

VS

exec('convert photo.jpg -resize 320x240 t_photo.jpg');

What do you think?

Also every good thumbnail should be sharpened a bit...

exec('convert photo.jpg -resize 320x240 -unsharp 1.5×1.0+1.5+0.02 t_photo.jpg');

http://net.tutsplus.com/tutorials/php/create-instagram-filters-with-php/




回答2:


From my experience, I think ImageMagick renders a better quality. It's also known that ImageMagick is faster, specially if you use it throught command line (or PHP exec("convert ...") (see this benchmark for example)

About quality, I've found this, in SO : How to stop GD2 from washing away the colors upon resizing images?




回答3:


GraphicsMagick

After trying both and finding that ImageMagick was better but in the end I choose neither and went with GraphicsMagick instead.

GraphicsMagick is originally derived from ImageMagick 5.5.2 as of November 2002 but has been completely independent of the ImageMagick project since then. Since the fork from ImageMagick many improvements have been made (see NEWS) by many authors using an open development model but without breaking the API or utilities operation.

  • GM is more efficient so it gets the job done faster using fewer resources.
  • GM is much smaller and tighter (3-5X smaller installation footprint).
  • GM is used to process billions of files at the world's largest photo sites (e.g. Flickr and Etsy).
  • GM does not conflict with other installed software.
  • GM suffers from fewer security issues and exploits.
  • GM valgrind's 100% clean (memcheck and helgrind).

Also..

  • PECL package, gmagick PHP wrapper class
  • PHP Docs: Gmagick
  • GraphicsMagick for node.js


来源:https://stackoverflow.com/questions/9914718/choosing-between-imagemagick-gd-for-thumbnail-creation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!