Page 1 of 4
Processing for print
Posted: 2015-02-06T10:40:02-07:00
by afre
Hello All, I have been using
IM for photo processing and would like to prepare the image for print (e.g. Walmart). This is what I have so far:
Code: Select all
FOR %i in (*.PNG) DO convert -quiet %i -alpha Remove -alpha Off -filter Lanczos -distort Resize 1350x1350^^ -density 300 -units PixelsPerInch -fill White -undercolor "Graya(50%,.5)" -gravity NorthWest -annotate 0 " %date% " -profile C:\Windows\System32\spool\drivers\color\sRGB_v4_ICC_preference.icc %~ni_A.PNG
Thoughts:
- The resultant PNG doesn't appear to have a tagged color space. It works when I change the format to JPG.
- I don't quite know how to control the text watermark. What I really want is a box that wraps tightly around the text.
Re: Processing for print
Posted: 2015-02-06T11:03:42-07:00
by fmw42
Always best to provide your IM version and platform (appears to be Windows) and one sample of source and destination images for people to test. You can post to dropbox.com and put the URLs here. One of the Windows users likely can help with your code.
It is hard to know what is wrong without seeing your output and clear explanation of the problem relative to that output.
PNG format only supports sRGB and pixels per centimeter. But IM will convert your pixels per in to the proper pixels per cm.
I do not see anything that is obviously wrong with your IM code, but I am not a Windows user.
Often printers need CMYK profile/colorspace and PNG does not support that. So use jpg or tiff if that is the case.
Another way to generate your image is to create a new text image with label: and then put a box (border) around it if needed and then composite it over your background image where you want it.
Also you can use -draw rather than -annotate. But nothing wrong with annotate, either.
see
http://www.imagemagick.org/Usage/text/
Re: Processing for print
Posted: 2015-02-06T12:21:19-07:00
by snibgo
1. On sRGB profiles in PNG, see
http://www.imagemagick.org/script/comma ... php#define , the text under "png:exclude-chunk=value"
2. You have a space character within the string on each side of %date%, so you will get blank space left and right. I like that, but you might not. If you really want a tight box, the best way is to create it as a separate image, trim it, and composite it.
3. I don't know why you have both "-alpha remove" and "-alpha off". Does "-fill white" do anything? Your output filenames are included in your inputs, so if you re-run the command you'll get an extra set of files.
Re: Processing for print
Posted: 2015-02-06T15:56:42-07:00
by afre
Hello
fmw42,
snibgo, I am using ImageMagick 6.9.0-3 Q16 x64 from the Windows binary. My intention is to make prints of a photo collection at say Walmart. I am making some assumptions about their requirements. I am not in a hurry to print. I am just playing around with code to figure out what I want and what IM can do. I hope to use code that is as simple and generalized as possible. The command:
Code: Select all
convert -quiet logo: -alpha Remove -alpha Off -filter Lanczos -distort Resize 1350x1350^^ -density 300 -units PixelsPerInch -fill White -undercolor "Graya(50%,.5)" -gravity NorthWest -annotate 0 " %date% " -profile C:\Windows\System32\spool\drivers\color\sRGB_v4_ICC_preference.icc logoprint.JPG
Breakdown:
- Remove alpha from enfuse output.
- Set size and DPI according to Wikipedia.
- Set fore- and background of watermark.
- Place it in the corner with arbitrary text.
- Assign color space lost in processing.
PNG/JPG: My intention was to output JPGs. Mentioned PNG because I didn't know why it couldn't take the
-profile tag.
Watermark: I have read all of the related documentation. It is difficult to put together, so I can only describe what I want.
- Text on rectangle that fits to its extent. Option to add padding to rectangle. In this way, the text would be centred all of the time.
- I prefer the total height to be x pixels and that the operations keep type distortion to a minimal.
Re: Processing for print
Posted: 2015-02-06T16:28:51-07:00
by fmw42
Try using label: to create a transparent background image with the text to a specified height. Then -trim +repage -border to add the border padding. Then -gravity XX -geometry +X+Y -compose over -composite to place the result over the background image where you want.
See
http://www.imagemagick.org/Usage/text/#label
http://www.imagemagick.org/Usage/layers/#convert
http://www.imagemagick.org/Usage/compose/
http://www.imagemagick.org/Usage/crop/#trim
http://www.imagemagick.org/Usage/crop/#border
Re: Processing for print
Posted: 2015-02-07T16:20:38-07:00
by afre
Hello
fmw42, I am beginning to understand what my underlying trouble is. I get confused when trying to combine too many ideas at once. I normally use
IM options separately in short commands. However, that creates intermediary files and decreases overall quality.
With your hints, I can do:
Code: Select all
convert -background "Graya(50%,.5)" -fill White -font Calibri -pointsize 12 label:"ABC %date% 2014:12:13 23:24:26" -trim +repage logo: +swap -gravity NorthWest -composite mark.PNG
What I don't know is how to manipulate
logo: and
label: separately:
- My source file has XX dimensions @ YY DPI.
- I would like to manipulate it before compositing it with the label.
- I would like the image to have AA dimensions @ BB DPI and its label to have the size of CC pt @ DD DPI. (In fact, BB = DD.)
Re: Processing for print
Posted: 2015-02-07T16:34:39-07:00
by fmw42
Put each in parenthesis and you can process them separately with other commands relevant to each. see
http://www.imagemagick.org/Usage/basics/#parenthesis On windows, leave off the \, so you only have ( .... ).
For label, leave off the pointsize and just use the desired width or height, not both. See
http://www.imagemagick.org/Usage/text/#label_bestfit
You cannot have one density for text and one for the image. The resulting image will be the one you set the density on.
Re: Processing for print
Posted: 2015-02-15T14:55:15-07:00
by afre
fmw42, 2 more questions:
- Low contrast photos: Would it be better to use say -linear-stretch or its relatives at the beginning or the end of the pipe? Before or after something like your redist or my non-IM CLAHE script? Currently, I use -linear-stretch 10x10. I understand it isn't a simple answer and it depends on what I am trying to achieve, but I would like to know your thoughts on this.
- There are remarks in the forum and documentation on anti-aliasing. In what situations would it be entirely appropriate to disable it? E.g., in the context of this topic, small text watermarking.
Re: Processing for print
Posted: 2015-02-15T15:06:54-07:00
by fmw42
1. I would just use -auto-level or -contrast-stretch 0 at the beginning to stretch to full dynamic range.
2. Depends upon what you want with your watermark. If it is too small text you may or may not want anti-aliasing. It depends upon how the text renders.
All just my opinions out of context to your problems.
Re: Processing for print
Posted: 2015-02-16T00:20:16-07:00
by snibgo
afre wrote:Low contrast photos: Would it be better to use say -linear-stretch or its relatives at the beginning or the end of the pipe? Before or after something like your redist or my non-IM CLAHE script? Currently, I use -linear-stretch 10x10. I understand it isn't a simple answer and it depends on what I am trying to achieve, but I would like to know your thoughts on this.
As a rule of thumb, equalising histograms will override any previous auto-level or linear-stretch.
I have published Windows scripts for CLAHE etc with IM at
http://im.snibgo.com/eqlimit.htm . They need IM to be built with my process modules.
Re: Processing for print
Posted: 2015-02-16T12:16:58-07:00
by afre
Things usually occur to me
after I write something
Yes, histogram equalization should already do the job. However, there are a number of reasons that low contrast is still an issue for me. Perhaps, among other things:
- My limit is too high; I'm not equalising enough.
- Enfuse is giving too much weight to the original image.
snibgo, I'm well aware of your scripts. I like them as much as
fmw42's. However, I have a hard time getting them to work. Building and setting things up is a barrier that I am still working to overcome. The current CLAHE code I am using is the best from what I've seen. There's zero support for that one, so once I get your scripts working, I can't wait to see how it compares.
Re: Processing for print
Posted: 2015-02-16T15:37:23-07:00
by snibgo
I should probably have expanded a little: equalising the histogram, or making it any particular shape, will overwrite previous histogram modification such as auto-level. This also applies to adaptive HE. However, contrast-limited HE doesn't make a particular shape, and will depend somewhat on the histogram of the input.
Re: Processing for print
Posted: 2015-02-16T18:21:45-07:00
by fmw42
The current CLAHE code I am using is the best from what I've seen
Did you write this yourself or get it from somewhere else such as OpenCV? If from yourself, can you make that publicly available perhaps for implementation in Imagemagick?
Re: Processing for print
Posted: 2015-02-18T13:40:41-07:00
by afre
snibgo: I am currently stuck at
Build "-process" modules. When I do
I get
Code: Select all
convert: unrecognized list type `modules' @ error/convert.c/ConvertImageCommand/2025.
fmw42: It isn't my code
and it appears that the author doesn't want us to contact him. Fortunately, I see that the code is GPL. I don't know if it will be useful for IM or anyone here, but it appears to be highly efficient and gives natural results—at least for my use cases. See:
Intro/Code, and after some digging,
Related Paper?
Re: Processing for print
Posted: 2015-02-18T14:24:47-07:00
by snibgo
It should be "-list module" (no "s").