Page 1 of 2
how to Watermark all images in sub folders use tile
Posted: 2016-07-11T00:06:18-07:00
by liyucmh
dear everyone
I use this to watermark pics in one folders with tile
Code: Select all
#!/bin/bash
for each in /mnt/hgfs/L/tempL/*.jpg
do
s=`du -k $each | awk '{print $1}'`
if [ $s -gt 10 ]; then
convert -resize 1766 -quality 75 $each $each
convert /mnt/hgfs/L/tempL/rotate_330_614.png -fill grey50 -colorize 40 miff:- | composite -dissolve 8 -tile - $each $each 2>/dev/null
echo "$each: done!"
fi
done
exit 0
now it only process pics in root TempL, how to modify this script to process all pics in folder tempL includes its sub folders
thanks!
Re: how to Watermark all images in sub folders use tile
Posted: 2016-07-11T09:36:49-07:00
by fmw42
As far as I know, Imagemagick does not traverse subdirectories. So you need to script finding each subdirectory and processing each image in the subdirectory.
Proper IM syntax reads the input image before processing such as -resize.
If you use the convert syntax for dissolve rather than composite, you do not need to do a pipe.
Re: how to Watermark all images in sub folders use tile
Posted: 2016-07-11T17:47:00-07:00
by liyucmh
fmw42 wrote:As far as I know, Imagemagick does not traverse subdirectories. So you need to script finding each subdirectory and processing each image in the subdirectory.
Proper IM syntax reads the input image before processing such as -resize.
If you use the convert syntax for dissolve rather than composite, you do not need to do a pipe.
can you help me, i am new to imagemagick, i do not how to do a pipe, can you help me write, thanks
Re: how to Watermark all images in sub folders use tile
Posted: 2016-07-11T18:17:10-07:00
by fmw42
can you help me, i am new to imagemagick, i do not how to do a pipe, can you help me write, thanks
Your code already has a pipe.
Code: Select all
convert /mnt/hgfs/L/tempL/rotate_330_614.png -fill grey50 -colorize 40 miff:- | composite -dissolve 8 -tile - $each $each 2>/dev/null
The pipe is the | symbol.
Perhaps if you provide an example of your various input images (separately) and output for one image, we can help better.
I am not quite sure what you are asking now.
Re: how to Watermark all images in sub folders use tile
Posted: 2016-07-11T18:33:51-07:00
by snibgo
liyucmh wrote:how to modify this script to process all pics in folder tempL includes its sub folders
That question is about scripting in bash, not about ImageMagick.
Re: how to Watermark all images in sub folders use tile
Posted: 2016-07-11T18:54:28-07:00
by liyucmh
snibgo wrote:liyucmh wrote:how to modify this script to process all pics in folder tempL includes its sub folders
That question is about scripting in bash, not about ImageMagick.
yes, so how to scripting in bash, i can process all pics, includes sub folders thanks,
Re: how to Watermark all images in sub folders use tile
Posted: 2016-07-11T19:24:29-07:00
by fmw42
yes, so how to scripting in bash, i can process all pics, includes sub folders thanks,
Your code is already scripting in bash. It starts with
#!/bin/bash
and does its looping in bash. Only the convert and composite commands are Imagemagick.
Re: how to Watermark all images in sub folders use tile
Posted: 2016-07-11T19:24:37-07:00
by liyucmh
fmw42 wrote:can you help me, i am new to imagemagick, i do not how to do a pipe, can you help me write, thanks
Your code already has a pipe.
Code: Select all
convert /mnt/hgfs/L/tempL/rotate_330_614.png -fill grey50 -colorize 40 miff:- | composite -dissolve 8 -tile - $each $each 2>/dev/null
The pipe is the | symbol.
Perhaps if you provide an example of your various input images (separately) and output for one image, we can help better.
I am not quite sure what you are asking now.
thanks for your reply
now this script can watermark all pics in root folder , but can not process sub folders, how to modified
Re: how to Watermark all images in sub folders use tile
Posted: 2016-07-11T19:27:39-07:00
by liyucmh
fmw42 wrote:yes, so how to scripting in bash, i can process all pics, includes sub folders thanks,
Your code is already scripting in bash. It starts with
#!/bin/bash
and does its looping in bash. Only the convert and composite commands are Imagemagick.
thanks, but it only process root folder TempL, do not process sub folders such as folder1 folder2 in the TempL, how to modify the bash, it can process all pics includes sub folders in TempL?
Re: how to Watermark all images in sub folders use tile
Posted: 2016-07-11T19:49:30-07:00
by fmw42
You will have to find or list all folders you want to process and loop over each one in bash with your script. So you need an outer loop over each folder.
Re: how to Watermark all images in sub folders use tile
Posted: 2016-07-11T19:55:31-07:00
by fmw42
Re: how to Watermark all images in sub folders use tile
Posted: 2016-07-11T20:12:06-07:00
by liyucmh
fmw42 wrote:You will have to find or list all folders you want to process and loop over each one in bash with your script. So you need an outer loop over each folder.
so how to write in one script, i am new to bash command, can you help me, thanks
Re: how to Watermark all images in sub folders use tile
Posted: 2016-07-11T22:22:36-07:00
by fmw42
This is not a bash or unix forum. This is an imagemagick forum. I suggest you request help on a unix bash forum.
Re: how to Watermark all images in sub folders use tile
Posted: 2016-07-12T00:25:46-07:00
by vonbiber
You could use the unix command 'find' to traverse all folders and subfolders.
Provided your pictures are all jpg, something like that will list all the jpg files
found in the top directory /mnt/hgfs/L/tempL and its subfolders:
Code: Select all
#!/bin/bash
find /mnt/hgfs/L/tempL/* -type f -name '*.jpg' | while read each
do
#display the name found: (replace the line echo "..." by the commands you you want to apply to process the $each file found)
echo "$each"
done
This assumes that your pictures are all *.jpg. In case some of them are *.JPG or *.Jpg, etc., use '-iname' instead of '-name'
option for
Re: how to Watermark all images in sub folders use tile
Posted: 2016-07-12T20:07:31-07:00
by liyucmh
vonbiber wrote:You could use the unix command 'find' to traverse all folders and subfolders.
Provided your pictures are all jpg, something like that will list all the jpg files
found in the top directory /mnt/hgfs/L/tempL and its subfolders:
Code: Select all
#!/bin/bash
find /mnt/hgfs/L/tempL/* -type f -name '*.jpg' | while read each
do
#display the name found: (replace the line echo "..." by the commands you you want to apply to process the $each file found)
echo "$each"
done
This assumes that your pictures are all *.jpg. In case some of them are *.JPG or *.Jpg, etc., use '-iname' instead of '-name'
option for
thanks
I have Replaced the for command with
Code: Select all
for each in `find /mnt/hgfs/L/tempL -name '*.jpg'`
now it can work well
but here are new problem, if the sub folder name contain special characters such as Korean word, special characters, it run wrong, how to process folder name that contain special characters ?