So i have imagemagick Version: ImageMagick 6.9.11-60
To make the process easier I created a ready png file with a repeating pattern at the right angle, with the right transparency which is always larger than input image to cover it. Unfortunately I am not able to make it work.I described what I want to achieve
1. I have an input image (image1) and a watermark (watermark.png). Watermark is a ready mesh with a repeating watermark with the appropriate transparency. Its length and width are always greater than the length and width of image1
2. Now I want to apply this watermark to the center of image1 and the center of watermark1
3. The next step is to be able to reduce the size of the watermark by for example 20% . The dimensions of image1 cannot be changed. The watermark should still be centered after reducing the dimensions.
4. the next step is to move the watermark by a certain number of pixels x and y
5. The last step is to cut out the unnecessary part of the watermark so that only the input image with the watermark remains.
Ideally, it would be possible to do all of this in one query where I can provide parameters such as:
- input image
- watermark image
- output image
- by how many percent to reduce the watermark
- by how many pixels X and Y to move the watermark
[EDIT]
in reference to the question I am attaching an example watermark and an image to apply the watermark to.
The wtarmark is already prepared with the appropriate transparency, shadows. The images to which I will apply the watermark are of different sizes and in different aspects but they will always fit within the watermark grid as in the images above
ok
2
Answers
I managed to cobble something together that more-or-less does the job. It reads the image files from the server, and stores the output on the server as well. It looks like this:
I think you can look up what the various Imagick methods exactly do in the documentation, but I added some comments to clarify them.
All paths have to be absolute paths, and the three other settings are integers. A use case could be:
Here the images and output are stored in the same location as the PHP script. The watermark is reduced by 10% and the offset x and y randomly moved by up to 25 pixels in either direction. The result looks like this:
Here is a short method in Imagemagick using -distort SRT with a computed viewport to do the cropping. The viewport is a global artifact, so it is stored past the composite where the two input images have been removed and their dimensions lost.