Processing for print

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
afre
Posts: 57
Joined: 2014-01-22T15:02:53-07:00
Authentication code: 6789

Processing for print

Post 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:
  1. The resultant PNG doesn't appear to have a tagged color space. It works when I change the format to JPG.
  2. I don't quite know how to control the text watermark. What I really want is a box that wraps tightly around the text.
Last edited by afre on 2015-02-15T14:04:42-07:00, edited 1 time in total.
ImageMagick 7.0.7-25 Q16 x64 2018-03-04 · Cipher DPC HDRI Modules OpenMP · Windows 7
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Processing for print

Post 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/
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Processing for print

Post 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.
snibgo's IM pages: im.snibgo.com
afre
Posts: 57
Joined: 2014-01-22T15:02:53-07:00
Authentication code: 6789

Re: Processing for print

Post 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:
  1. Remove alpha from enfuse output.
  2. Set size and DPI according to Wikipedia.
  3. Set fore- and background of watermark.
  4. Place it in the corner with arbitrary text.
  5. 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.
Last edited by afre on 2015-02-15T14:17:03-07:00, edited 1 time in total.
ImageMagick 7.0.7-25 Q16 x64 2018-03-04 · Cipher DPC HDRI Modules OpenMP · Windows 7
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Processing for print

Post 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
afre
Posts: 57
Joined: 2014-01-22T15:02:53-07:00
Authentication code: 6789

Re: Processing for print

Post 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:
  1. My source file has XX dimensions @ YY DPI.
  2. I would like to manipulate it before compositing it with the label.
  3. 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.)
ImageMagick 7.0.7-25 Q16 x64 2018-03-04 · Cipher DPC HDRI Modules OpenMP · Windows 7
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Processing for print

Post 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.
afre
Posts: 57
Joined: 2014-01-22T15:02:53-07:00
Authentication code: 6789

Re: Processing for print

Post by afre »

fmw42, 2 more questions:
  1. 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.
  2. 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.
ImageMagick 7.0.7-25 Q16 x64 2018-03-04 · Cipher DPC HDRI Modules OpenMP · Windows 7
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Processing for print

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Processing for print

Post 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.
snibgo's IM pages: im.snibgo.com
afre
Posts: 57
Joined: 2014-01-22T15:02:53-07:00
Authentication code: 6789

Re: Processing for print

Post by afre »

Things usually occur to me after I write something :lol: 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:
  1. My limit is too high; I'm not equalising enough.
  2. 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.
ImageMagick 7.0.7-25 Q16 x64 2018-03-04 · Cipher DPC HDRI Modules OpenMP · Windows 7
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Processing for print

Post 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.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Processing for print

Post 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?
afre
Posts: 57
Joined: 2014-01-22T15:02:53-07:00
Authentication code: 6789

Re: Processing for print

Post by afre »

snibgo: I am currently stuck at Build "-process" modules. When I do

Code: Select all

%im32f%convert -list modules
I get

Code: Select all

convert: unrecognized list type `modules' @ error/convert.c/ConvertImageCommand/2025.
fmw42: It isn't my code :lol: 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?
ImageMagick 7.0.7-25 Q16 x64 2018-03-04 · Cipher DPC HDRI Modules OpenMP · Windows 7
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Processing for print

Post by snibgo »

It should be "-list module" (no "s").
snibgo's IM pages: im.snibgo.com
Post Reply