generate 5000+ unique image files (.jpg) of 2MB size
-
- Posts: 9
- Joined: 2015-06-18T05:41:43-07:00
- Authentication code: 6789
generate 5000+ unique image files (.jpg) of 2MB size
Hi,
I need to generate 5000 unique image files (.jpg) of 2MB size. Can anyone help me in getting the command for generation this many unique file on x86_64 GNU/Linux Operating System. I can provide a sample image file if required.
Regards,
Sushil Kumar
I need to generate 5000 unique image files (.jpg) of 2MB size. Can anyone help me in getting the command for generation this many unique file on x86_64 GNU/Linux Operating System. I can provide a sample image file if required.
Regards,
Sushil Kumar
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: generate 5000+ unique image files (.jpg) of 2MB size
Can they all be the same size, in pixels? Then use plasma or noise to create an image. Put that inside a loop.
snibgo's IM pages: im.snibgo.com
-
- Posts: 9
- Joined: 2015-06-18T05:41:43-07:00
- Authentication code: 6789
Re: generate 5000+ unique image files (.jpg) of 2MB size
Yes Snibgo, If all files are of almost same size then it is well and good but content should not be same. i.e all images should be unique.
I will check plasma and noise function to create these images.
If any other suggestion it will be great.
Regards,
Sushil Kumar
I will check plasma and noise function to create these images.
If any other suggestion it will be great.
Regards,
Sushil Kumar
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: generate 5000+ unique image files (.jpg) of 2MB size
For example:
Code: Select all
for (( NDX=1; $NDX<10; NDX=$NDX+1 ));
do
echo $NDX;
convert -size 100x100 plasma: rnd_$NDX.jpg
done;
snibgo's IM pages: im.snibgo.com
Re: generate 5000+ unique image files (.jpg) of 2MB size
Use plasma:fractal to generate unique images. If you need to reproduce the sequence in the future, generate a vector of random seeds for each image and use the -seed option on your command line.
-
- Posts: 9
- Joined: 2015-06-18T05:41:43-07:00
- Authentication code: 6789
Re: generate 5000+ unique image files (.jpg) of 2MB size
Sure, Thanks Snibgo,
Hi Snibgo,
I am using 5 directory to run this script in parallel and each directory will generate 1000 files.So total target of 5000 files will be achieved soon.
I am sure that running from one location will generate all unique image files. Is their any change that if i run same script from 5 different directories then any image of one output directory may match in size and property of other output directory? I am using 5 directory of same machine.
Regards,
Sushil Kumar
Hi Snibgo,
I am using 5 directory to run this script in parallel and each directory will generate 1000 files.So total target of 5000 files will be achieved soon.
I am sure that running from one location will generate all unique image files. Is their any change that if i run same script from 5 different directories then any image of one output directory may match in size and property of other output directory? I am using 5 directory of same machine.
Regards,
Sushil Kumar
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: generate 5000+ unique image files (.jpg) of 2MB size
With a random number generator, there is always a chance that two numbers will be the same. In fact, it is guaranteed to generate a number twice if you run it for long enough.
You can introduce a non-random sequential number to ensure they are unique. For example, set the top-left pixel to rgb(0,0,0) in the first image, rgb(0,0,1) in the next, and so on.
You don't need any randomness. Just use "xc:" to set the entire image to a solid colour.
You can introduce a non-random sequential number to ensure they are unique. For example, set the top-left pixel to rgb(0,0,0) in the first image, rgb(0,0,1) in the next, and so on.
You don't need any randomness. Just use "xc:" to set the entire image to a solid colour.
snibgo's IM pages: im.snibgo.com
Re: generate 5000+ unique image files (.jpg) of 2MB size
You can ake a random threshold background image:
Then do this in a loop over s="0000" through "5000"
Code: Select all
convert -size 1024x768 xc:green -random-threshold 1x99% background.ppm
Code: Select all
convert background.ppm -fill white -draw 'scale 4,4 gravity center text 0,0 $s' -quality 98 image$s.jpg
-
- Posts: 9
- Joined: 2015-06-18T05:41:43-07:00
- Authentication code: 6789
Re: generate 5000+ unique image files (.jpg) of 2MB size
Hi Snibgo,
I believe i did almost same but generated files are not unique. The argument i passed is a number ( $I ). I passed value 4 so total 4X3=12 files got generated. but it seems all images generated by using one "colorBk" are of same property and size. So they are not unique.
=======================================
count=0
for colorBk in red blue green
do
echo "colorBk = $colorBk"
convert -size 1024x768 xc:$colorBk -random-threshold 1x99% background.ppm
for ((I=1; I<=$1; I++))
do
convert background.ppm -fill white -draw 'scale 4,4 gravity center text 0,0 "$I"' -quality 98 image$colorBk_$count.jpg
count=`expr $count + 1`
done
done
========================================
Please let me know if i am doing something wrong.
Regards,
Sushil Kumar
I believe i did almost same but generated files are not unique. The argument i passed is a number ( $I ). I passed value 4 so total 4X3=12 files got generated. but it seems all images generated by using one "colorBk" are of same property and size. So they are not unique.
=======================================
count=0
for colorBk in red blue green
do
echo "colorBk = $colorBk"
convert -size 1024x768 xc:$colorBk -random-threshold 1x99% background.ppm
for ((I=1; I<=$1; I++))
do
convert background.ppm -fill white -draw 'scale 4,4 gravity center text 0,0 "$I"' -quality 98 image$colorBk_$count.jpg
count=`expr $count + 1`
done
done
========================================
Please let me know if i am doing something wrong.
Regards,
Sushil Kumar
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: generate 5000+ unique image files (.jpg) of 2MB size
For the second convert, try:
Code: Select all
convert background.ppm -fill white -draw "scale 4,4 gravity center text 0,0 '$I'" -quality 98 image${colorBk}_$count.jpg
snibgo's IM pages: im.snibgo.com
-
- Posts: 9
- Joined: 2015-06-18T05:41:43-07:00
- Authentication code: 6789
Re: generate 5000+ unique image files (.jpg) of 2MB size
Thanks Snibgo,
It works.
Regards,
Sushil Kumar
It works.
Regards,
Sushil Kumar
-
- Posts: 9
- Joined: 2015-06-18T05:41:43-07:00
- Authentication code: 6789
Re: generate 5000+ unique image files (.jpg) of 2MB size
For everyone who needs this code is below.
=======================================
#!/bin/sh
convert -size 1024x768 xc:green -random-threshold 1x99% background.ppm
for ((I=1; I<=5000; I++))
do
convert background.ppm -fill white -draw "scale 4,4 gravity center text 0,0 '$I'" -quality 98 /opt/Loc1/image_$I.jpg
done
exit;
=======================================
=======================================
#!/bin/sh
convert -size 1024x768 xc:green -random-threshold 1x99% background.ppm
for ((I=1; I<=5000; I++))
do
convert background.ppm -fill white -draw "scale 4,4 gravity center text 0,0 '$I'" -quality 98 /opt/Loc1/image_$I.jpg
done
exit;
=======================================
Re: generate 5000+ unique image files (.jpg) of 2MB size
Note that "xc:green" is equivalent to "xc:#008000" not "xc:#00ff00". The latter is "lime" and would end up creating a small (18kbytes) solid lime-colored image with the number written on it.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: generate 5000+ unique image files (.jpg) of 2MB size
lime is also the same as green1 (not green as glennrp said). So lime and green1 are equivalent to #00ff00 or rgb(0,255,0).glennrp wrote:Note that "xc:green" is equivalent to "xc:#008000" not "xc:#00ff00". The latter is "lime" and would end up creating a small (18kbytes) solid lime-colored image with the number written on it.
-
- Posts: 9
- Joined: 2015-06-18T05:41:43-07:00
- Authentication code: 6789
Re: generate 5000+ unique image files (.jpg) of 2MB size
Thanks everyone. It was great help by all of you.