Page 3 of 3

Re: Multiple writes and pipes in a single command

Posted: 2016-06-06T14:11:34-07:00
by dannygreer
I think I found a workaround, not sure its the most efficient way of working, but this got the result that I want except that the transparent watermark background is white:

Code: Select all

#!/bin/sh

INPUTFILE='image.jpg'
MPRNAME='12345'
WATERMARK='MyWatermark.png'
ICCPROFILE='sRGB.icc'
ORIGINALSIZE=`identify $INPUTFILE | awk -F ' ' '{print $3}'`
HPRSIZE=$ORIGINALSIZE
LPRSIZE='2000x2000'
SCRSIZE='1100x1100'
PRESIZE='450x450'
THMSIZE='150x150'
COLSIZE='75x75'

convert $INPUTFILE -depth 8 -flatten \( $WATERMARK -write mpr:$MPRNAME +delete \) \
    \( -size $HPRSIZE tile:mpr:$MPRNAME \) \
    \( -clone 0 -clone 1 -compose dissolve -define compose:args=15 -composite \) \
    -delete 1 -quality 82 -intent relative -black-point-compensation -profile $ICCPROFILE +profile "!iptc,*" -write mpr:$MPRNAME \
    -delete 1 -write hpr.jpg +delete mpr:$MPRNAME -delete 0 -write hpr_wm.jpg +delete \
    mpr:$MPRNAME -resize $LPRSIZE -write mpr:$MPRNAME \
    -delete 1 -write lpr.jpg +delete mpr:$MPRNAME -delete 0 -write lpr_wm.jpg +delete \
    mpr:$MPRNAME -resize $SCRSIZE -write mpr:$MPRNAME \
    -delete 1 -write scr.jpg +delete mpr:$MPRNAME -delete 0 -write scr_wm.jpg +delete \
    mpr:$MPRNAME -resize $PRESIZE -write mpr:$MPRNAME \
    -delete 1 -write pre.jpg +delete mpr:$MPRNAME -delete 0 -write pre_wm.jpg +delete \
    mpr:$MPRNAME -resize $THMSIZE -write mpr:$MPRNAME \
    -delete 1 -write thm.jpg +delete mpr:$MPRNAME -delete 0 -write thm_wm.jpg +delete \
    mpr:$MPRNAME -resize $COLSIZE -write mpr:$MPRNAME \
    -delete 1 -write col.jpg +delete mpr:$MPRNAME -delete 0 col_wm.jpg

Re: Multiple writes and pipes in a single command

Posted: 2016-06-06T14:36:06-07:00
by dannygreer
The transparent background on the watermark is dark on a light image and light on a dark image. Maybe the problem is with dissolve? I have tried modulate, but it was worse.

One other issue I'm having with this code block is that I want the first hpr jpeg without watermark to happen before converting to sRGB, but whenever I try to move first save to jpeg before the conversion I start getting additional copies of saves.

Re: Multiple writes and pipes in a single command

Posted: 2016-06-06T16:39:10-07:00
by snibgo
dannygreer wrote:.. the transparent watermark background is white ...
You can change it to black. For example, change the first line of convert to:

Code: Select all

convert $INPUTFILE -depth 8 -flatten \( $WATERMARK -background Black -alpha Background -write mpr:$MPRNAME +delete \) \

Re: Multiple writes and pipes in a single command

Posted: 2016-06-07T11:57:33-07:00
by dannygreer
Here is my version of the working command in the form of a bash script.

Code: Select all

#!/bin/sh

INPUTFILE=$1
MPRNAME='12345'
WATERMARK=$2
ICCPROFILE='sRGB.icc'
ORIGINALSIZE=`identify $INPUTFILE | awk -F ' ' '{print $3}'`
HPRSIZE=$ORIGINALSIZE
LPRSIZE='2000x2000'
SCRSIZE='1100x1100'
PRESIZE='450x450'
THMSIZE='150x150'
COLSIZE='75x75'

convert $INPUTFILE -depth 8 -flatten -write hpr.jpg \
    -intent relative -black-point-compensation -profile $ICCPROFILE +profile "!iptc,*" \
    \( $WATERMARK -write mpr:$MPRNAME +delete \) \
    \( -size $HPRSIZE tile:mpr:$MPRNAME \) \
    \( -clone 0 -clone 1 -compose multiply -composite \) \
    -delete 1 -write mpr:$MPRNAME \
    -delete 0 -quality 82 -write hpr_wm.jpg +delete \
    mpr:$MPRNAME -resize $LPRSIZE">" -write mpr:$MPRNAME \
    -delete 1 -quality 82 -write lpr.jpg +delete mpr:$MPRNAME -delete 0 -write lpr_wm.jpg +delete \
    mpr:$MPRNAME resize $SCRSIZE">" -write mpr:$MPRNAME \
    -delete 1 -quality 82 -write scr.jpg +delete mpr:$MPRNAME -delete 0 -write scr_wm.jpg +delete \
    mpr:$MPRNAME resize $PRESIZE">" -write mpr:$MPRNAME \
    -delete 1 -quality 82 -write pre.jpg +delete mpr:$MPRNAME -delete 0 -write pre_wm.jpg +delete \
    mpr:$MPRNAME -resize $THMSIZE">" -write mpr:$MPRNAME \
    -delete 1 -quality 82 -write thm.jpg +delete mpr:$MPRNAME -delete 0 -write thm_wm.jpg +delete \
    mpr:$MPRNAME $COLSIZE">" -write mpr:$MPRNAME \
    -delete 1 -quality 82 -write col.jpg +delete mpr:$MPRNAME -delete 0 col_wm.jpg
I'm still struggling with a -compose option and watermark that will be consistently visible and unobtrusive on all images whether dark black, bright white or anywhere between and need to figure out how I will size the watermark before tiling it so that its size is consistent between different images.

I don't like that I'm loading a stack of two images from the mpr, then deleting one of them, but have been unable to load just one of the images from the mpr stack.

Re: Multiple writes and pipes in a single command

Posted: 2016-06-07T13:18:04-07:00
by dannygreer
fmw42 wrote:try this with the images from that reference

Code: Select all

convert logo.jpg \( -size 180x180 tile:wmark_image.png \) \
-compose dissolve -define compose:args=15 -composite result.png
see the last section at http://www.imagemagick.org/script/compose.php for dissolve and the -define above it. Also http://www.imagemagick.org/script/comma ... php#define
Image

It turns out that the code above is not the equivalent to

Code: Select all

convert wmark_image.png miff:- |\
  composite -dissolve 15 -tile  -  logo.jpg wmark_dissolve_tile.jpg
Image

You will notice the blue gown gets lighter in the recommended code. I hadn't noticed before. The problem, I have discovered is that the transparency in the png is ignored in the new method. I have also discovered that it is the tile: that removes the alpha. Simply running convert -size 200x200 tile:wmark_image.png result.png on an image with a transparent background shows this.

Re: Multiple writes and pipes in a single command

Posted: 2016-06-07T14:31:02-07:00
by dannygreer
dannygreer wrote:
fmw42 wrote:try this with the images from that reference

Code: Select all

convert logo.jpg \( -size 180x180 tile:wmark_image.png \) \
-compose dissolve -define compose:args=15 -composite result.png
see the last section at http://www.imagemagick.org/script/compose.php for dissolve and the -define above it. Also http://www.imagemagick.org/script/comma ... php#define
It turns out that the code above is not the equivalent to

Code: Select all

convert wmark_image.png miff:- |\
  composite -dissolve 15 -tile  -  logo.jpg wmark_dissolve_tile.jpg
You will notice the blue gown gets lighter in the recommended code. I hadn't noticed before. The problem, I have discovered is that the transparency in the png is ignored in the new method. I have also discovered that it is the tile: that removes the alpha. Simply running convert -size 200x200 tile:wmark_image.png result.png on an image with a transparent background shows this.
It appears that the correct command to replace the sample code would be

Code: Select all

convert logo.jpg \( -background none -size 180x180 tile:wmark_image.png \) -compose dissolve -define compose:args=15 -composite result.png