I have a lot of JPEG files and I want to add them as layers to a PSD file using ImageMagick
I found several scripts to do the opposite, extract the layers from a PSD file. I don't want that.
I just want to take several JPEG pictures and add them as layers to a PSD (photoshop) file and name those layers as the JPEG file name. I found a way to create composite images with ImageMagick but all the examples I saw create a PNG or GIF file. I need to create a PSD layered file.
A couple of notes first:
1/ The first layer in a psd file is all the layers merged and you would need to create that first.
2/ For some reason the first layer using the code below drops the first layer e.g image1.png so create a blank layer to use as the first layer.
3/ The layers in my test were renamed to L000001 etc.
The answer to the first part of your question is:
convert image1.png image2.png image3.png
But I do not know how to keep the image names as the layer names
Related
I need to create a layered PSD file from a list of PNG images using the GIMP command line, in which each PNG image is one layer of a generated PSD file. I found one git related to this. It runs successfully without any error, but it didn't create a PSD file at a given location. Is there something I am doing wrong here?
I want to overlay multiple PNG images of different sizes on a transparent canvas using ImageMagick. First I create a transparent canvas of some fixed size, say like
convert -size 1500x1000 canvas:transparent PNG32:canvas.png
Then I loop over my images in order to add each image to the canvas
convert canvas.png nthimage.png -gravity Center -geometry xResxYres+xcoord+ycoord -composite canvas.png
This works fine, but I may overlay as many as 10 pictures and I do this for thousands of n-tuples of images, so a faster solution would be appreciated. So my question: Can I also do this in one step instead of creating the canvas first and then adding a single image at a time?
Edit: I use ImageMagick 7.0.11-13 on macOS 10.15.7. I run ImageMagick from within a python script, so a file containing a list of input files can be generated if needed. For concreteness, say my input files are file_1.png up to file_n.png with sizes A1xB1 up to AnxBn and should be placed at coordinates +X1+Y1 up to +Xn+Yn with respect to the center of the canvas and the output file is output.png and should have size 1500x1000.
I really wouldn't recommend shelling out subprocesses from Python to call ImageMagick thousands of times. You'll just end up including too much process creation overhead per image, which is pointless if you are already running Python which can do the image processing "in house".
I would suggest you use PIL, or OpenCV directly from Python, and as your Mac is certainly multi-core, I would suggest you use multi-processing too since the task of doing thousands of images is trivially parallelisable.
As you haven't really given any indication of what your tuples actually look like, nor how to determine the output filename, I can only point you to methods 7 & 8 in this answer.
Your processing function for each image will want to create a new transparent image then open and paste other images with:
from PIL import Image
canvas = Image.new('RGBA', SOMETHING)
for overlay in overlays:
im = Image.open(overlay)
canvas.paste(im, (SOMEWHERE))
canvas.save(something)
Documentation here.
Similar to this “Diff” an image using ImageMagick but lets say I have 2+ images of different sizes. Say from a game with multiple screenshots and I just want to extract the "coins" image so I detect it in a tool like Sikuli which accepts a transparent PNG and ignores the transparent areas.
I am thinking it is something with the compare tool to create a mask for one of the images then apply the mask using magick/convert to extract the final PNG.
Say I have three images where each are slightly off...
I want to somehow extract the following from the three images.
Note I am not really requiring a full imagemagick solution. I am thinking that the alignment best be done with another tool like Gimp, but I am not sure how to even create a "difference layer" that I can shift around so I can align the images.
I'm building an image based off of user input -- the background will either be an image or a color, and then a few other images may or may not be composed on top.
Checking through the paperclip docs, it mentions that you can use ImageMagik to post-process images, and that post-processing will never fire if it doesnt already have an image.
If I am able to make the imagemagik scripts to compose/color/resize an image, is there a way for it to generate the image, or will I need to include some sort of hackish pixel to upload (and then postprocess in to the image I want)?
ImageMagick can generate a starting image for you, consisting of a simple rectangle filled with a single color. For example, this will generate a 150x100 red image:
convert -size 150x100 xc:"#ff0000" starting_image.png
I would try the following:
Have a default image in my app's assets folder
If the model to be saved has no attachment then I would assign it the one mentioned above: a_model.image = File.open('...')
Then, upon save of the a_model the post-processing should take place normally
As far as I know, Apple has new approach to create images for 3x called PDF vector image.I have a PSD file (with multiple layers for many icons) and now I want to export all layers to pdf vector image to use asset catalog.
I also refer this tutorial but i don't understand how to do for step 1.
http://martiancraft.com/blog/2014/09/vector-images-xcode6/
How can i do that? Please give some solution to do that. Thanks in advance.
You can use vectorized PDF files in Xcode in the 1x slot.
When you compile your project, Xcode automatically will generate the PNG files for each required resolution (1x, 2x and 3x). (You final project won't have the PDF file)
To use that feature you need to have a vectorized image (SVG, EPS or AI) and print them to vectorized PDF. (PSD is not a vectorized format)
I usually use SVG files and I print to Vectorized PDF with this page http://www.fileformat.info/convert/image/svg2pdf.htm
If you have a PSD file, you can save your layers to PNG in the 3x resolution and put each PNG in the 3x slot. When you do that, XCode automatically will generate the 1x and 2x images resizing the 3x image.
Hope this helps