How to convert distort perspecitve leads to "# fatal/mogrify.c/MogrifyImage/1423" - imagemagick-convert

I have to distort some pictures in the perspective way with Imagemagick. One of the four given points in the pictures stay in the same position and the other 3 points should distort around the first point.
In my last researches I only found a solution for the output "convert: Memory allocation failed 'name.jpg'". So I changed the the memory value in my policy.xml to the value of my whole RAM.
If I write
convert building.jpg -matte -virtual-pixel transparent \
-distort Perspective \
'4,126 4,126 7,39 4,39 85,0 100,39 86,127 100,126' \
building_pers.png
in the console (given by my professor), I get the output in the heading.
Now I don't know, what I should do. I hope you can help me.
P.S.: I have some difficulties with English, so I hope you can forgive my possible mistakes. Please answer in a way easy to understand.
Thank you very much.

With Imagemagick 7, you must change "convert" to "magick". Try that. Also does your Imagemagick version list jpg for a delegate? Check by magick -version and report all that is returned. How big is your image? Remove -matte. That was deprecated in Imagemagick 7. It should not be needed in your command. Your code is Unix syntax and not for plain Windows.
Try removing all \ and make one long command line as follows in a normal Window terminal. If you are in a Windows Unix terminal, you would have had to install a Unix version of Imagemagick.
So in normal Windows, try
magick.exe building.jpg -virtual-pixel transparent -distort Perspective '4,126 4,126 7,39 4,39 85,0 100,39 86,127 100,126' building_pers.png

Related

Scale PostScript Image via GhostScript

I have a postscript image, which I wanted to scale down to 84x84 pixels.
I tried the following line ( and different ones, but this one is the furthest I got ):
gs -sOutputFile=somefile.bmp -sDEVICE=bmpgray -q -g84x84 -dDEVICEWIDTH=84 -dDEVICEHEIGHT=84 -dPDFFitPage frames/frame_00000055.ps
This did not achieve what I wanted (all it does is showing a white image).
You have several problems with that command line. There is no command line switch -dDEVICEHEIGHT or -dDEVICEWIDTH, the relevant switches are -dDEVICEHEIGHTPOINTS and -dDEVICEWIDTHPOINTS. You should never attempt to set the media size in two different ways anwyay, it will only lead to problems of some kind. You've specified -dPDFFitPage, but you appear to have supplied a PostScript program as the input.
Unsurprisingly, the PDFFitPage parameter does not scale PostScript.
When you are having problems of any kind, its best not to mute the application using -q (for quiet), in case its trying to tell you something.
Try using -dFitPage instead of -dPDFFitPage. If that still doesn't work, then I'll need to see your PostScript program.
84x84 pixels is tiny, its entirely conceivable that the result of downscaling a PostScript program could result in no pixel centers being touched, in which case the output will indeed be blank.

RGB to CMYK Conversion and Mask/Crop - Photoshop

This may sound like stupid question, but for me it's important.
I don't have much experience with using Photoshop, because Inkscape is perfect for my needs (web). Now I would need to create something and print it. I know that color mode for printing should be CMYK.
Because I am more familiar with Inkscape(that does not support CMYK), can I create PDF in that program and then import it into Photoshop and change color mode to CMYK. Is that valid? It shows that color mode is changed, but is that all? Because this is not for me and I just want to know if person that I wouk this for will not have any problems when it comes to printing. How can I make sure that conversion to CMYK was good?
One more question. In Inkscape I can not crop image, but I can mask or clip it. Basically, image still exist, but you see only portion of it. When it comes to printing will printer print full image or just that portion of it or I will need to crop image?
For most part, when you print an RGB file on your printer, the printer will convert it to CMYK. It's ability to do so "well" will depend on how accurate you need it to be & what color profile it is printing from (sRGB generally turns out better than say AdobeRGB).
The main reason for you to convert a file is so that you can make any fine tune adjustments to the image after the change. So you're not leaving it to the printer to decide and possibly mess up.
I'm not familiar with InkScape so don't know how it'll export said artwork. When you open it in Photoshop however, you will be able to see if it tacked it on there. Then you can crop if need be.
Hope that helps.

ImageMagick negates image after composite Multiply

The servers where I work upgraded some libraries and now I am getting a weird behaviour out of ImageMagick version 6.7.8-9.
I am using the command
composite -compose Multiply bkg.gif overlay.gif output.gif
which used to put overlay.gif, which is a mostly white image, on top of bkg.gif. Now the same thing is happening but bkg.gif is negated! I have tried to change from Multiplyto Screen, which, according to the docs is the same thing but negates both images and back, but the output was the same.
I have worked around this by negating image bkg.gif before doing the same operation but this is not correct and I still have to do this is many scripts that use the same command, so I would like to effectively solve the problem or at least understand it.
Why is this happening? I apologize but I cannot provide the images we are using.

Merge two pngs via command line tool in windows?

I'm looking for a tool I can use via command line (windows 7) to merge two equally sized pngs. I'm not having much luck with search so far as most tools I've seen are pretty heavy applications which don't seem to target simple manipulations.
I want to overwrite the bits in the opaque base image with the non-transparent pixels in the overlay image. I have photoshop CS4 as well, but haven't had much luck in finding the relevant command line arguments.
ImageMagick has a command line tool called composite which will do what you want. Distributions available for Windows, Mac, Linux etc. I've just tested it with two transparent PNGs and works as expected.
composite foreground.png background.png newimage.png

Properly converting a CMYK image to RGB with RMagick

I have been using the below to do a color conversion
if #image.colorspace == Magick::CMYKColorspace
# #image.colorspace #=> CMYKColorspace=12
#image.colorspace = Magick::RGBColorspace
#image = #image.negate
end
It works, approximately, but the color luminosity is off. The fact that I need to negate the image leaves a very bad smell.
The documentation mentions using color_profiles, but beyond that I can not find much.
I am now trying
#image = #image.quantize(16777216, Magick::RGBColorspace)
And the colors are better, but still off.
Thanks Pekka, you tipped me off to the answer (+1).
You must have ImageMagick compiled with the Little Color Management System (LCMS) installed. This may already be the case if an installer or package was used. But I was compiling from source. It was as simple as installing LCMS from source and rebuilding ImageMagick (./configure; make; make install).
In ImageMagick the below works well to reproduce accurate color:
convert FILENAME -profile /PATH_TO_PROFILE/sRGB.icm OUT.jpg
So in RMagick I use the below:
if #image.colorspace == Magick::CMYKColorspace
# Adjust the path as necessary
#image.color_profile ="/usr/local/share/ImageMagick-6.5.4/config/sRGB.icm"
end
#image.write("out.jpg") { self.quality = 85 }
I've spent a long time trying to go from a CMYK EPS to a RGB PNG using RMagick and Rails. Hopefully this will be of use to someone:
def convert_image_from_cmyk_to_rgb( image )
#puts image.alpha?
if image.colorspace == Magick::CMYKColorspace
image.strip!
image.add_profile("#{Rails.root}/lib/USWebCoatedSWOP.icc")
image.colorspace == Magick::SRGBColorspace
image.add_profile("#{Rails.root}/lib/sRGB.icc")
end
image
end
You can download the ICC files direct from Adobe at http://www.adobe.com/support/downloads/iccprofiles/iccprofiles_win.html
The only thing I haven't been able to suss is how to maintain transparency. The EPS I want to use has a transparent background which is being turned into white. Unfortunately I can't do something like image.transparent( "white" ) as I have white in the image that I want to keep as white.
If I uncomment the puts image.alpha? in the above code it returns false.
Does anyone know if what I'm trying to do is possible with the current version of RMagick, as I'm beginning to wonder if importing CMYK EPSs with transparency isn't supported.
Thanks!
The incoming files, in this case, do
have a profile. I will investigate
some more. I got lost with the color
profiles (like where do I download
them? the ICC site was not much help)
You are not the only one confused; I was too. There are discussions on the ImageMagick site that might be worth siftirng through: Here As far as I understood back then, properly working with profiles is possible when the profile used can be identified (e.g. a monitor profile) or is embedded in the file (which can be done at least for TIFF and JPG in Photoshop, I think). Check e.g. this: Here. Good luck.
I found that The Who's command line solution worked beautifully, but the RMagick solution did not work for me.
To get it to work in RMagick, I instead I had to use the Magick::Image#add_format method, which, according to the docs, will allow you to specify an source and destination profile. It looks like this:
if img.colorspace == Magick::CMYKColorspace
img.add_profile(RGB_COLOR_PROFILE)
end
RE: LCMS on Centos 5.5, be sure to download and build the latest LCMS from source (vs. yum install). Otherwise, IM won't find LCMS at build and you'll be scratching your head, like me, wondering why LCMS isn't included in IM delegate libs.

Resources