IM equivalent of GIMP - Levels - Output

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?".
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: IM equivalent of GIMP - Levels - Output

Post by fmw42 »

You simply create a hald image in IM

Code: Select all

convert hald:8  hald_8.png
The larger the hald value, the more accurate the colors are. But hald: 8 should be good enough for saving your result as jpg.

Now take hald_8.png to GIMP and apply all your processing to it that you used on your image. Then save the result as hald_8_processed.png or whatever name you want. Note, you should not use a Hald image if your processing does any blurring or sharpening. It is only for point operations that are applied to every pixel, such as color change, brightness or contrast, but no masking either.

Now take it back to IM and apply it to your image

Code: Select all

convert web_wh.jpg hald_8_processed.png -hald-clut web_wh_processed.jpg
That is all you need to do.

If you want to apply it to a large number of images. Create a loop over each image and apply the same hald_8_processed.png to each image. The looping structure is different for Windows and Linux/Mac OS. But the IM command is the same. You can save the loop and command as a script and apply it to any image

script infile outfile

or in Windows, the bat script can be a drag and drop.

If you are on unix, I can help with the script. Others can help if on Windows.
rossdv8
Posts: 47
Joined: 2014-03-12T21:54:20-07:00
Authentication code: 6789

Re: IM equivalent of GIMP - Levels - Output

Post by rossdv8 »

Thanks Fred,

I thought I somehow had to extrapolate the information from an image I had already modified and somehow create a HALD table from that. But you point out that it is so simple. Again, my brain just doesn't see the obvious any more.

I don't always use such a high saturation, but ofen I do need the other changes. So I can make two LUTs to cover the majority of my work. Mostly I just need to get rid of the muddy haze left across an image by the junk cameras I have to use (they have to be cheap enough to be disposable). But generally I need to brighten them and match them to my ink. You and snibgo have given me a whole other area to explore.

UPDATE

Ok, I'm sold. I have wasted so much time trying to automate the adjustments in GIMP by tweaking IM curve and level settings. I had read the HALD -CLUT information but could not work out how to convert an image to a table. I followed Fred's instruction, created a table, did the mods to that table of colours in GIMP and applied the result to an image. It was almost exactly what GIMP gave me, with the differenc so small a normal person would barely notice.

I then applied the same table to the image useed in this post and all the colours, contrasts etc are perfect.

What a wonderful tool.

Thanks again, especially to Fred and snibgo, whose websites have provided me with a lot of starting points and to Anthony who seems to be a driving force here also.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: IM equivalent of GIMP - Levels - Output

Post by fmw42 »

You can always create a base Hald processed image and then when applying it, use other IM commands to post process that to fine tune further with any further adjustments or specialized changes you want.

HALD image and -hald-clut is a great process for duplication processing in GIMP or Photoshop (or other GUI-based tools) and replicating them efficiently in IM if you have lots of images to process (of course with some limitations on what functionality that can be replicated)

Each HALD image is like a present in GIMP or Photoshop.
rossdv8
Posts: 47
Joined: 2014-03-12T21:54:20-07:00
Authentication code: 6789

Re: IM equivalent of GIMP - Levels - Output

Post by rossdv8 »

I'm almost ashamed to ask this, because it should be such a simple fix. But here goes.
This is a BASH question really so I feel pretty stupid for forgetting how to do it.

I am using a simple script to apply HALD-CLUT to multiple images. But the output is ending up with duplicated extensions. I'm obviously working with digital photos,and they are jpegs. I want my output for various reasons, to be png files.

Ok. Assuming my input file is nara.jpg, I get something like this as output: HALD-SAT25+noicc+nara.jpg.png

I would prefer this: HALD-SAT25-nara.png

Please excuse the messy commenting in the script. It is an old habit from the days many years ago when I actually wrote programs :-) These days I just can't remember simple stuff. Pretty obvious how it works.

The script I am using is this. It is not elegant, but since my brain injury I really do need the simplest approach these days with as few fancy bits to remember as possible:

Anyway, I've searched everything I can find on getting rid of that "+noicc+ (and) .jpg" string simply and just can't find it and cannot remember.
Thinking more about it, I should be able to use

basename $i (instead of +$file) but I just can;t think what parameters to use..
UPDATE - Ok, no variation of basename $i seems to work.

UPDATE 2 - I changed my script and stripped the '+' out everywhere that '+$' appeared. now I can get an output like:
HALD-SAT30noiccnara.jpg.png

But I am still getting the 'xxxx.jpg.png'.

There must be a way to strip the .jpg and end up with only my .png. It isn't critical - just annoying.

Thanks,

RossD

********************
#!/bin/bash
# Strip any embedded ICC profiles
for file in `ls *.jpg`; do
# convert $file +profile "*" 'noicc'+$file
convert $file +profile "*" 'noicc'$file
done
# Create an output folder
mkdir output
# Apply HALD-CLUT to image
## This works now - at last ##
for file in `ls noicc*`; do
# convert $file Hald_8-Sat30_S-Curve_Lev-IN15-Gam1.5.png -hald-clut 'HALD-SAT30'+$file.png
convert $file Hald_8-Sat30_S-Curve_Lev-IN15-Gam1.5.png -hald-clut 'HALD-SAT30'$file.png
# note - removed ALL + signs from file name args
# move the enhanced file to the output folder
# mv 'HALD-SAT30'+$file.png output
mv 'HALD-SAT30'$file.png output
done
# get rid of noicc file before starting over
rm noicc*

***********************
Last edited by rossdv8 on 2014-08-06T18:17:37-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: IM equivalent of GIMP - Levels - Output

Post by fmw42 »

to get the basename of a file use

basename=`convert image -format "%t" info:`

see
http://www.imagemagick.org/script/escape.php
rossdv8
Posts: 47
Joined: 2014-03-12T21:54:20-07:00
Authentication code: 6789

Re: IM equivalent of GIMP - Levels - Output

Post by rossdv8 »

Thanks Fred,

No combination of that basename hint did anything useful :(

But I'm almost there. I've changed the script above, so now I am just getting a double file extension (xxxx.jpg.png) on the output file. Just have to find a simple way to get rid of the .jpg and leave only the png extension.

I updated the earlier post to reflect that.

Thanks. I know it is only a BASH problem, but I'm sure you have seen it. If you have a suggestion, that would be appreciated. In the mean time I'll go back to trial and error. It worked with the + signs :o

UPDATE - I thought this:
for file in *.png; do mv $file ${file%%.jpg.png}.png; done
might solve the problem, but now running the script on 6 files I get one png renamed with a spare .png extension for the number of input files. So instead of 6 files with a .png extension, I get one file like :xxxx.png.png.png.png.png.png

The great news is that the 'jpg really is gone :lol:

I'm not sure if I am enjoyihg trying to script again or if I am going to die from frustration.
Last edited by rossdv8 on 2014-08-06T18:39:27-07:00, edited 2 times in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: IM equivalent of GIMP - Levels - Output

Post by fmw42 »

Suppose you want to get the base name and change the output suffix to png. Lets say your infile is HALD-SAT25+noicc+nara.jpg (not sure what the pluses are for?)

Code: Select all

infile="HALD-SAT25+noicc+nara.jpg"
basename=`convert "$infile" -format "%t" info:`
outfile="${basename}.png"
convert "$infile" "$outfile"
If this is not the issue, then please clarify and provide your exact command line.
rossdv8
Posts: 47
Joined: 2014-03-12T21:54:20-07:00
Authentication code: 6789

Re: IM equivalent of GIMP - Levels - Output

Post by rossdv8 »

Thanks Fred,

HALD-SAT25+noicc+nara.jpg.png is the outfile.
The pluses were added dueing the processing as part of the batch to process multiple files.

Each time I run a new process on a file I add that process to the name. So when I strip the ICC profile from a file called nara.jpg, the script would add (+$) the noicc to the name. So output is something like naranoicc.jpg.

Then I apply the HALD table and name the file for what is done. so HALD-SAT30 tells me I used the HALD table that had 30% saturation.
Output file would ideally be called nara_HALD30.png

But my scripting is not good enough so I am getting an output file with .jpg.png and the plus signs.

I've managed to get rid of the plus signs simply by not using them in the command (which was from a windows example for something) - it seems the command works fine in Linux without them.

Now I have managed to remove the .jpg.png double extension and only have the output file as .png using this:

for i in *.png
do
mv "$i" "`echo $i | sed 's/.jpg//'`"
done

It may be clumsy, and it might not be correct, but it works.

Thanks for prompting me.

I appreciate the mind jolt.
Post Reply