MagickWand is not suit, because it doesn't work on simple hosting.
I'm searching for image framework to solve following tasks:
1) Combine images
2) Resize images
I tried to use codeigniter component, but it cannot combine images.
There are at least two: GD, and ImageMagick are both quite popular. GD is well-suited to procedural code, while ImageMagick is well-suited to object-oriented code.
I think GD Library is all you need.
Related
is there any way to connect GIMP with PHP and use its libraries?
It seems that all
i do my development use linux as a production server
example for resise image or croping
There is also the GD library which can be used with PHP directly.
http://php.net/manual/en/ref.image.php
imagecrop — Crop an image to the given rectangle
imagescale — Scale an image using the given new width and height
First thing: for resizing or cropping, you really should use some PHP library that integrates with Imagemagick, or something along that.
Now, to actually answer the question "is there any way to connect GIMP with PHP?" - The answer to that is "not directly".
Supposing you want to do extend use of Image manipulation algorithms for some serious project - GIMP engine nowadays is driven by GEGL (Generic Graphics Library) - which has support to binding with any other language through gobject introspection. Now,, gobject introspection can theoretically work with any language - but looking for Gobject Introspection for PHP yields some blog postos form 2011, and some early-stage projects on github. Therefore, although GEGL is what could provide you full image maniulation capabilities, I don't think it can be directly itegrated with PHP due to missing gobject integration. There should be a lot of ways of usig it indirectly, though - by creating some local web-service that would use GEGL to process operations described in XML, for example - such a service could be made in Python or C.
And, finally, for using GIMP's PDB itself, one could craft a Python script that would work as a local webservice relay to GIMP's PDB -so it is also possible in an indirect way.
I like the ImageMagick library, it is more powerful than the GD library. However it doesn't come pre-installed with php you have to do it manually, but if you can do it, it's easy to install with:
sudo apt-get install php5-imagick
The website: https://www.imagemagick.org
The PHP docs: http://php.net/manual/en/book.imagick.php
I recently started using imagemagick with php and
I'm relatively new with both of these, IM and PHP.
So, I'm here to ask for some help/suggestion(s).
First
If lets say a user uploads a gif or a png image on
my site and I want it converted to jpg, is there any
command like for example.$image->convert($file,'.jpg)
or the convert command is accesible only thru exec() ?
like for example exec(convert picture.png to picture.jpg)
Second
What if for again, the user uploads gif/png on the site
and I resize the image to a specified width/height and
write the image, with the writeImage function of IM like this:
$image->writeImage(basename.$ext) where $ext = jpg.
Will this work properly,is this a good practice? I assume this will
only rename it but still, I don't see a problem in this... o.O
Oh sorry one more question, I'm not very familiar with exec,
is it better using imagemagick using exec(), does it improve
speed, load etc?
I can't answer your questions directly but thought I point you to a few resources:
Regarding which is better, exec or the PHP extension, I asked this same question a few months ago:
Should I use a PHP extension for ImageMagick or just use PHP's Exec() function to run the terminal commands?
For all Image Magick PHP functions you should look up the official guide:
http://www.php.net/manual/en/book.imagick.php
I switched from Image Magick to Graphics Magick as I heard it has better performance. It is a fork of Image Magick with an emphasis on performance. Large sites like Flickr and Etsy use it:
http://www.graphicsmagick.org/
This guide got me started:
http://devzone.zend.com/1559/manipulating-images-with-php-and-graphicsmagick/
And they have their own manual on php.net:
http://php.net/manual/en/book.gmagick.php (most of the commands are identical to Image Magick's)
I prefer using exec() as it is supported a lot better than Imagick ( the example code you posted ), easier to use and supports all the operators ( depending on your version ) which again Imagick does not.
Some of the Imagick code works differntly in the different versions; there are a lot more Imagick examples around than there were a couple of years ago when I first started looking at it.
Saying that Imagick can be faster and is/can be? built into php although some people have trouble installing it.
I belive that this site http://valokuva.org/?cat=1 belongs to a Imagick developer and has lots of examples.
My site www.rubblewebs.co.uk/imagemagick has lots of examples of php with exec( )
As to your other two questions yes you can change the file type with Imagick and I am not sure about basename.$ext - why not try it? As long as basename does not have an extension it may work but you might need to include basename.$ext in quotes.
As to speed it dpends sometimes GD is faster other times Imagick or Imagemagick. You can always do some tests. I did some a year or so ago and you can try the code on your server. http://www.rubblewebs.co.uk/imagemagick/speed/Speed_tests_1.pdf
Background: For an university project I have to use PHP5 to create a web application that also deals with images. I'm not allowed to use any external APIs, frameworks or AJAX.
Is there a native function to resize images in PHP5?
(I know a can specify both width and height for an img tag, but that resizing is done on the client. I'd rather save downsized images on the server.)
The GD library has been bundled with PHP since 4.3, and will do what you want: http://uk.php.net/manual/en/book.image.php. You'll probably want something like imagecopyresampled.
Most PHP installations come bundled with the GD library. In fact, I've yet to come across a PHP installation that doesn't have GD bundled.
I am a newbie with php and I want to play with php and images uploaded.
What are the most used PHP image manipulation classes ?
If you're just starting I'd suggest taking a look at the GD functions. They come with PHP (assuming you have GD enabled).
If you need more power then there's ImageMagick, but you have to install it yourself.
Most used is hard to find but a large list of php classes can be found here:
http://phpclasses.fonant.com/browse/class/11.html
You can do alot with the built in GD graphics library:
http://php.net/manual/en/book.image.php
I am building an easy to use OO image manipulation library with intuitive API. Its publicly available on GitHub - https://github.com/avalanche123/Imagine
I am working on a project that resizes images using PHP's GD library. I would like to be able to add the option to use seam carving to resize images but don't want to require something like ImageMagick (which can do seam carving with its liquid rescale feature) to accomplish this.
Since there are no built-in seam carving functions in GD, is there a way to perform seam carving on an image using PHP's GD library or other built-in PHP functions? Alternatively, do you know if seam carving will eventually be baked into GD?
While you could implement this using GD, you're best bet if you can control the server environment is to create an external script/program to carve an image. PHP is going to be a huge bottleneck doing those kind of calculations. Even basic matrix transformations run a serious risk of hitting the max execution times set in PHP configs.
I don't see why it shouldn't be possible with GD, but I can tell you it would be slow.
Imagemagick is open source, so I guess you could translate the function to PHP.