Re: Automatic Picture Sizing and Renaming

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11Dec2006 22:55, Thom Paine <painethom@xxxxxxxxx> wrote:
| I have several hundred pictures I'd like to resize to 800x600 and I'd
| also like to randomize their names to have them shuffle on a computer
| screen for a screensaver.
| 
| I've been reading a bit and have some of a command figured out.
| 
| #convert -interlace NONE -geometry 800x600
| /home/workgroup/pics/image1.jpg
| /home/workgroup/pics/image1.resized.jpg

Ouch. I hope you're not doing this as root!
Do it all as a normal user whenever possible.

| I'm not sure how to get this to work on a whole directory full of pictures.
| Should I run this in some sort of a while do loop? I'm a rookie with
| bash, but have been reading a bit trying to understand it.

"sh", not "bash".

| Since I want them all to be random, is it better to rename them all
| first with a random number between 1000 and 1999 with pic in front or
| should I resize them first, delete the bigger original (because it
| will be a copy) and then rename them? And what happens if I happen to
| already have a picture named that?

I'd:
  - convert to the right size. Probably keep them all in a special
    directory.
  - make a random collection of symlinks to the converted files,
    in yet another directory.

This way you can incrementally add more pictures and only do the
conversion for the new images, _and_ you can reshuffle just by remaking
the random symlinks.

| 1. Take all images in a source directory and convert them to 800x600 
| resolution.
| 2. Rename all images in said source directory to a random number
| between 1000 and 1999 and then have the image name come out something
| like pic1717.jpg
| 3. Delete the images in the source directory making room for another
| batch to convert and display.

Short on disc space? Ok then.

Something like this:

  cd the-directory-of-original-images

  # make resized images as needed
  [ -d RESIZED ] || mkdir RESIZED
  for img in *.jpg
  do
    resized=RESIZED/$img
    # skip images already resized
    [ -s "$resized" ] && continue
    convert -interlace NONE -geometry 800x600 "$img" "$resized"
  done

  # create directory of links
  rm -rf RANDOM
  mkdir RANDOM
  cd RESIZED
  ls \
  | shuffle \
  | \
  { n=0
    while read img
    do
      n=`expr $n + 1`
      ln "$img" ../RANDOM/$n.jpg
    done

At this point there should be random resize images in the directory
"the-directory-of-original-images/RANDOM".

That's untested. You will need the "shuffle" script, fetchable here:

  http://www.cskk.ezoshosting.com/cs/css/bin/shuffle

You can remove the original images if you like. Just make sure any new
images have unqiue names, never seen before.

Cheers,
-- 
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/

Senior ego adepto, ocius ego eram.

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux