Automatiškas nuotraukų dydžio sumažinimas

D
  • 25 Geg '13

Seniau žinojau, kad yra tokia programa kuri padėtu mano atveju, bet niekaip neatgaminu kokia.
Esmė tokia, tarkim turiu daug nuotraukų iš fotoaparato, kurių didelė rezoliucija. Reikia tą rezoliucija pakeisti į tinkamą kelti į internetą, tai yra tarkim 800*600 px. Kai nedaug tų nuotraukų, tai paprastai per gimp ar panašiai tą padarau ir viskas. Tačiau dabar jų nemažai yra ir tai būtu laiko gaišimas.
Tiesiog reiktu, kad visas nuotraukas esančias kataloge pakeistu iš dabartinės rezoliucijos iki mano nurodytos ir dar būtu idealu, bet nebūtina, kad jpg kokybę sumažinti iki 80-90 proc, kad mažiau vietos užimtu nuotrauka. Bet paskutinis dalykas neprivalomas.
Gal kas pamenate kokia programa man pagelbėtu tai atlikti kelių mygtuku paspaudimu?

N
  • 25 Geg '13

Jei terminalas tamstos nesibaido, tai gal toks variantas tiktų?
http://playingwithsid.blogspot.com/2010 ... shell.html

EDIT:
beje,

$ man convert

išspjuvė dar vieną raktą, kurio norėjai:

-quality value JPEG/MIFF/PNG compression level

D
  • 25 Geg '13

Terminalas labai puikus variantas. Juo ir pasinaudosiu. O programa irgi įsirašysiu, manau irgi pravers.
Ačiū.

S
starka
don Pedrilio
  • 26 Geg '13

Yra papildinys Gimpui- Gimp plugin David's Batch Processor. Su juo galima visas foto iškart tvarkyti (mažinti kokybę, dydį ir pan.). Arba jei naudoji Gnomą ar Mate, tai lengvai viskas padarome per Nautilus script:

#!/bin/sh
#made by tester8, based on Orlando De Giorgi's scripts
for file in "$@"
do
convert "$file" -scale 800x800 "$file"
done

arba

#!/bin/bash
#
#  Resize Image Nautilus Script v1.0
#
###
# Configuration
#

# Available image sizes
#  * first value is default value
#  * must correspond to script name and symlinks (see README)
SIZES=(800 1024)

# Image quality in percent
QUALITY=70

#
# End of configuration
###

# Check if ImageMagick commands are found
for command in convert identify
do
    if [ ! $(which $command) ]
    then
        zenity --error --text "Could not find \"$command\" application.\n
Make sure ImageMagick is installed and \"$command\" is executable."
        exit 1
    fi
done

# Prevent splitting of $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS on spaces by
# setthing Bash Internal Field Seperator to newline
IFS="
"

# Get file paths
FILES=($NAUTILUS_SCRIPT_SELECTED_FILE_PATHS)
FILES_COUNT=${#FILES[@]}

# Process files, if there are any
if [ $FILES_COUNT -gt 0 ]
then
    # Use script name to select target size
    for size_option in ${SIZES[@]}
    do
        if [ $(expr match "$(basename "$0")" ".*$size_option.*") -gt 0 ]
        then
            size=$size_option
            break
        else
            # Set to default size
            size=${SIZES[0]}
        fi
    done

    # Use plural/singular for progress message
    if [ $FILES_COUNT -gt 1 ]
    then
        file_string="files"
    else
        file_string="file"
    fi

    # Initialise progress bar file counter
    current_file=1

    # Loop through files
    for image_file in ${FILES[@]}
    do
        # Check if file is an image
        if [ $(identify "$image_file") ]
        then
            # Create image directory if it does not exist yet
            target_dir=$(dirname $image_file)"/"$size"px"
            if [ ! -d $target_dir ]
            then
                mkdir $target_dir
            fi

            # Resize image if it does not exit yet
            target_file=$target_dir"/"$(basename "$image_file")

            if [ ! -e "$target_file" ]
            then
                convert -resize $size"x"$size -quality $QUALITY "$image_file" "$target_file"
            fi

            # Send percentage to Zenity progress bar
            percentage=$(echo "$current_file * 100 / $FILES_COUNT" | bc)
            current_file=$((current_file + 1))
            echo $percentage
        fi
    # Pipe loop output to Zenity progress bar
    done | zenity --progress --title="Resizing images" --text="Processing $FILES_COUNT "$file_string"..." --auto-close
else
    echo "Please run this script via Nautilus (GNOME file manager)"
fi

ir daugiau tų scriptų galima paieškoti

D
  • 26 Geg '13

Na, pasinaudojau pačiu elementariausiu scriptu, jau vakar pasiūlytu.
Gal kam pravers:

#!/bin/bash
for i in *.JPG; do convert $i -resize 800x600 -quality 80% $(basename $i .JPG)-s.jpg; done

Visas nuotraukas esančias kataloge, turinčias .JPG formatą (linuxe .JPG ir .jpg failai skiriasi) sumažina iki 800*600 px, sumažina kokybę iki 80 proc, ir išsaugo nauju pavdinimu pridedant prie senojo "-s", bei pakeičia formatą į .jpg (iš .JPG).