Merge images php
I have many images with equal sizes (width and height).
There can be more than 50 different images.
I want to merge them on X
and Y
axes.
On X
axe 5 items and the rest on Y
.
For example, if we have 30 images, there will be 6 lines of images, 5 per l开发者_运维问答ine, like:
00000
00000
00000
00000
00000
00000
Its better to save all of them into single .png
How do I do this?
If you want to work with PHP's internal GD image library, imagecopy()
will help.
However, if the images are large, you may get into trouble with PHP's memory limit. In that case, if it's available on your server, it might be more feasible to use ImageMagick on the command line. It's also quite easy. These manual pages show two ways of achieving this:
- Appending images
- Montage into columns
the most simple way of running an ImageMagick command from within PHP is
exec("convert image.jpg image.gif"); // converts image.jpg into image.gif
you need this installed on server side to work, however. If in doubt, ask your hosting provider whether this is possible.
Adjust the command line to your needs according to the examples in the manual.
Are there any specific reasons for needing php, You could use server side javascript and the html 5 canvas element to merge the images together. Sample code can be found here on this question: Drawing multiple images to a canvas using image.onload
精彩评论