Page 1 of 2
opacity inner boarder to pic
Posted: 2018-01-12T03:32:47-07:00
by Crys
Hello,
I got a lot of holyday photos, which I want to edit: every photo should get the same inner boarder and a short text, from the exif data.
The photos have different sizes, but this shouldn’t matter to the boarder.
1.) a inner boarder of 40px at all sizes, 20px at the bottom. The boarder has a opacity of 40% of black.
2.) a text, starting at the right bottom, going to the left. The Text should be a comment exported from Lightroom (but in example it could be “exif:model”)
The boarder should look like this:
How do I start?
I tried sth. like this:
Code: Select all
convert %START% -auto-orient %TARGET%
convert %TARGET% -gravity SouthEast -pointsize 72 -draw "text 0,0 'Hello World'" %TARGET%
convert %TARGET% -stroke black -strokewidth 40 -fill transparent -draw "stroke-opacity 0.4 rectangle 20,20 1000,500" %TARGET%
I'm working with a bat-file ...
But I don’t know to continue.
Re: opacity inner boarder to pic
Posted: 2018-01-12T08:43:49-07:00
by GeeMack
Crys wrote: ↑2018-01-12T03:32:47-07:00I tried sth. like this:
Code: Select all
convert %START% -auto-orient %TARGET%
convert %TARGET% -gravity SouthEast -pointsize 72 -draw "text 0,0 'Hello World'" %TARGET%
convert %TARGET% -stroke black -strokewidth 40 -fill transparent -draw "stroke-opacity 0.4 rectangle 20,20 1000,500" %TARGET%
I'm working with a bat-file ... But I don’t know to continue.
A command like this will give a result very much like you've described...
Code: Select all
convert %START% -auto-orient -bordercolor white -gravity north ^
( -clone 0 -fill black -colorize 40%% ) ^
( -clone 0 -shave 40x20 -chop 0x20 -border 1 ) ^
-delete 0 -geometry +0+40 -composite ^
-gravity southeast -fill white -pointsize 72 -annotate +0+0 "Your Text" %TARGET%
That makes a clone of the input image and colorizes it with 40% black.
Then it makes another clone and shaves the edges, 40 pixels off each side, 40 pixels off the top, and 20 pixels off the bottom, and puts a one pixel white border around it.
It deletes the input image and composites the shaved image over the 40% blackened image, centered left to right and 40 pixels down from the top.
Then it resets the gravity to "southeast", sets the fill to "white", and annotates the image with "Your Text".
If you want to match the border on your example image, you can easily add another 5 pixel white border right before the final output.
Since you're using it in a BAT script I used two percent signs on the "40%%" black. From the command line it would only need one.
Re: opacity inner boarder to pic
Posted: 2018-01-12T13:21:57-07:00
by Crys
Thanks for your quick answer GeeMack!
I see, the problem is, that I don’t understand the syntax. I got still one problem and one thing I don’t understand:
If I try to read the exif information noting happens. As image viewer I use IrfanView and this tool shows me some exif information of my pic, put with the following noting happens:
Code: Select all
identify -format "%[EXIF:*]" %START%
When I use this, I got some information, but nothing useful:
Code: Select all
identify -format * %START%
JPEG 1280x960 1280x960+0+0 8-bit sRGB 427975B 0.000u 0:00.001
Is this a batch problem?
And I want to have a second inner boarder
Your white boarder makes a problem with the inner pic, it is 1px at the wrong position. But I like to have a 60% darker boarder between the normal pic and the 40% dark boarder. But I don’t know how to cut this ‘clone’. Can you help me please?
My try:
Code: Select all
set TEXT="My long Text is here"
convert %START% -auto-orient -gravity north ^
( -clone 0 -fill black -colorize 40%% ) ^
( -clone 0 -shave 40x20 -chop 0x20 ) ^
-delete 0 -geometry +0+40 -composite ^
( -clone 0 -fill black -colorize 60%% ) ^
( -clone 0 -shave 60x40 -chop 0x20 ) ^
-delete 0 -geometry +0+60 -composite ^
-gravity southeast -fill rgba(255,255,255,0.70) -font Calibri -pointsize 40 -annotate +60+30 %TEXT% ^
-gravity southeast -fill rgba(0,0,0,0.70) -font Calibri -pointsize 40 -annotate +62+32 %TEXT% ^
%TARGET%
Re: opacity inner boarder to pic
Posted: 2018-01-12T14:14:09-07:00
by Bonzo
What EXIF data do you want?
Re: opacity inner boarder to pic
Posted: 2018-01-12T15:44:08-07:00
by fmw42
Post the image that you think has EXIF data to some free hosting service that does not change the data or format (such as dropbox.com) and put the URL here, so we can examine the image meta data.
Re: opacity inner boarder to pic
Posted: 2018-01-13T00:36:33-07:00
by GeeMack
Crys wrote: ↑2018-01-12T13:21:57-07:00But I like to have a 60% darker boarder between the normal pic and the 40% dark boarder. But I don’t know how to cut this ‘clone’. Can you help me please?
You can create several images in a stack by cloning the input image inside parentheses a few times, and cropping, shaving, and colorizing each clone as necessary. Merge the layers then apply your text.
Code: Select all
set TEXT="My long Text is here"
convert %START% -auto-orient ^
( -clone 0 -colorize 40%% ) ^
( -clone 0 -shave 40x20 -chop 0x20 -set page +40+40 -colorize 60%% ) ^
( -clone 0 -shave 60x40 -chop 0x20 -set page +60+60 ) ^
-layers merge ^
-gravity southeast -font Calibri -pointsize 40 ^
-fill rgba(255,255,255,0.70) -annotate +60+30 %TEXT% ^
-fill rgba(0,0,0,0.70) -annotate +62+32 %TEXT% ^
%TARGET%
The first layer is the original input. The second layer is a clone of the original and colorized 40% black. The third layer is a clone of the original shaved 40 pixels on top, left, and right, and 20 pixels on the bottom, and colorized 60% black. The fourth layer is another clone shaved 60 pixels on top, left, and right, and 40 pixels on the bottom.
Notice I didn't use "-geometry" and "-composite" there. Instead I used "-set page ..." to specify the offset locations where each clone gets placed when they're merged down. Then I used "-layers merge" to flatten all the images down onto the ones below.
For your text, you should only need to set the "-font" and "-pointsize" once unless you have a reason to change them.
Re: opacity inner boarder to pic
Posted: 2018-01-13T07:26:01-07:00
by Crys
Oh, I see my mistake:
GeeMack wrote: ↑2018-01-12T08:43:49-07:00Since you're using it in a BAT script I used two percent signs [...]
With two % it works. But how can I use this information?
How to put it into a batch variable?
Code: Select all
identify -format "%%[exif:GPSImgDirection]" %START%
identify -format "%%[exif:ImageDescription]" %START%
Bonzo wrote: ↑2018-01-12T14:14:09-07:00What EXIF data do you want?
The
ImageDescription and
GPSImgDirection.
fmw42 wrote: ↑2018-01-12T15:44:08-07:00
Post the image that you think has EXIF data to some free hosting service [...]
https://anonfile.com/YeW6x4dbb6/DSCF6780.jpg
http://metapicz.com/#landing?imgsrc=htt ... CF6780.jpg
I would also like to use the xmp:Label …
But I don’t know how to combine the information in batch.
And thank you again GeeMack. I have another question, I want to merge the image with a wind rose and want to rotate the wind rose by the gps coordinats. but the whole image is rotating by the following code:
Code: Select all
convert %START% -auto-orient ^
( -clone 0 -fill black -colorize 40%% ) ^
( -clone 0 -shave 40x20 -chop 0x20 -set page +40+40 -colorize 60%% ) ^
( -clone 0 -shave 41x21 -chop 0x20 -set page +41+41 ) ^
-layers merge ^
-gravity southeast -font Calibri -pointsize 40 ^
-fill rgba(255,255,255,0.70) -annotate +60+30 %TEXT% ^
-fill rgba(0,0,0,0.40) -annotate +62+32 %TEXT% ^
%TARGET%
composite -gravity Southwest -geometry 150x1500+50+50 -dissolve 70%% -rotate 45 %WINDROSE% %TARGET% %TARGET%
Re: opacity inner boarder to pic
Posted: 2018-01-13T08:14:38-07:00
by GeeMack
Crys wrote: ↑2018-01-13T07:26:01-07:00With two % it works. But how can I use this information?
How to put it into a batch variable?
Code: Select all
identify -format "%%[exif:GPSImgDirection]" %START%
identify -format "%%[exif:ImageDescription]" %START%
Try using those directly as the arguments to your "-annotate" operations...
Code: Select all
... -annotate +60+30 "%%[exif:GPSImgDirection]" ...
Re: opacity inner boarder to pic
Posted: 2018-01-13T11:27:58-07:00
by Crys
Thanks GeeMack, this was to easy
And I found out how to rotate the wind rose, but now I got the problem that there is a (maybe 1px) with boarder around the rotated input:
Code: Select all
convert %START% -auto-orient ^
( -clone 0 -fill black -colorize 40%% ) ^
( -clone 0 -shave 40x20 -chop 0x20 -set page +40+40 -colorize 60%% ) ^
( -clone 0 -shave 41x21 -chop 0x20 -set page +41+41 ) ^
-layers merge ^
-gravity southeast -font Calibri -pointsize 40 ^
-fill rgba(255,255,255,0.70) -annotate +60+30 "%TEXT%" ^
-fill rgba(0,0,0,0.40) -annotate +62+32 "%TEXT%" ^
( %WINDROSE% -gravity Southwest -geometry +50+50 -rotate %ANGLE% -transparent white ) ^
-composite %TARGET%
How did I get this away?
Re: opacity inner boarder to pic
Posted: 2018-01-13T11:31:47-07:00
by fmw42
Add a -fuzz XX%% before -transparent white. Try 10%% or 20%%. Increase until the white border goes away. (Double %% for windows bat script)
Re: opacity inner boarder to pic
Posted: 2018-01-13T12:57:18-07:00
by Crys
Thx, I tried this already. But it works only for > fuzz 60%
Re: opacity inner boarder to pic
Posted: 2018-01-13T13:01:15-07:00
by fmw42
You could shave a pixel or two off of each side after making it transparent using -shave 1x1 after -transparent white. If the size is important then do -shave 1x1 -bordercolor none -border 1x1. That will add back 1 pixel of transparency after shaving.
If that does not work, then post a link to the image so we can see what is the issue.
Re: opacity inner boarder to pic
Posted: 2018-01-13T13:06:10-07:00
by Crys
Thanks to every body, for the great and quick help.
If some one want to try the script, I just let it run, while exporting from Lightroom:
Code: Select all
@echo off
set START=%1
set WINDROSE="f:\Desktop\ImageMagick Test\wind-rose3.png"
identify -format "%%[exif:ImageDescription]" %START% > temp.txt
set /p TEXT=<temp.txt
identify -format "%%[exif:GPSImgDirection]" %START% > temp.txt
set /p ANGLETEST=<temp.txt
set ANGLE=%ANGLETEST:~0,-6%
convert %START% -auto-orient ^
( -clone 0 -fill black -colorize 40%% ) ^
( -clone 0 -shave 40x20 -chop 0x20 -set page +40+40 -colorize 60%% ) ^
( -clone 0 -shave 41x21 -chop 0x20 -set page +41+41 ) ^
-layers merge ^
-gravity southeast -font Calibri -pointsize 40 ^
-fill rgba(255,255,255,0.70) -annotate +60+30 "%TEXT%" ^
-fill rgba(0,0,0,0.40) -annotate +62+32 "%TEXT%" ^
( %WINDROSE% -gravity Southwest -geometry +40+20 -rotate %ANGLE% -fuzz 60%% -transparent white ) ^
-composite %START%
Re: opacity inner boarder to pic
Posted: 2018-01-13T13:13:40-07:00
by fmw42
You should not have to write strings to a text file only to read them back into a variable. If desired, you also can combine the two identify command into one and save that to a variable. Such as follows. Sorry I do not code in Windows so do not know how to put that into a variable. But I think it is does with set.
Code: Select all
identify -format "%%[exif:ImageDescription]\n%%[exif:GPSImgDirection]\n" %START%
Re: opacity inner boarder to pic
Posted: 2018-01-13T13:45:59-07:00
by GeeMack
Crys wrote: ↑2018-01-13T13:06:10-07:00Thanks to every body, for the great and quick help.
As suggested by
fmw42, you can avoid writing and reading temporary files by setting variables directly from the output of a command. The method in Windows is a little weird, but it works. Try these two commands in a BAT script...
Code: Select all
for /f "delims=" %%A in ( 'identify -format "%%[exif:ImageDescription]" %START%' ) do set TEXT=%%A
for /f "delims=" %%A in ( 'identify -format "%%[exif:GPSImgDirection]" %START%' ) do set ANGLETEST=%%A
Now the variables %TEXT% and %ANGLETEST% will contain the outputs of the two "identify" commands.