Tuesday, June 13, 2017

Generating one image from multiple image using Imagick.

When I completed this feature in Laravel PHP frameworks last night, I got so hyped up, feeling so achieved. Then I thought, maybe I should share my excitement with someone. But then I realize, not many people understand this kind of excitedment, in the end, it is just a syok sendiri things.

So this Imagick can put many images into one image dynamically. You can set the image size (width x height), then decide which image to be the first in the code, the margin from the left and top. Once you tried one or two, you will feel it is very easy. If you need save, let say 5 images in first row and 2 images in second row, some condition checking need to be done for the minimum width of the whole image being generated. 

So first step
- check which row has more images
- use that max images count times the width of each image
- then the total had to be add with the gap size of each image. 
- After that, calculate number of rows (in this case it's 2)
- Then use the number of rows times the height of each image and add the gap of each image again.
- After setting the height and width of the main container, create new imagick object with the image that wanted to be input into the main container
- Attach it into the main container with the margin.
- Continue attach more images and in the end, just export it as a file name.

I will share some code and example in my next post. :-) 

1 comment:

  1. 1xbet korean bitcoin betting site | KKROKO.TV
    1xbet korean bitcoin betting site; videodl.cc Online soccer; youtube mp3 Live basketball; Sportsbetting in Korea. We are all about one. 1xbet

    ReplyDelete