BLAG

BLAG Forums
It is currently Sat Dec 20, 2014 12:57 pm

All times are UTC




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Jan 02, 2008 8:17 am 
Offline

Joined: Sun Sep 10, 2006 6:44 am
Posts: 14
As per the subject, I have a lot of jpg files I want to resize. I can do this from the gimp but it is a bit time consuming. Is there a command line tool I can build into a batch file to compress all the files in one go?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 02, 2008 8:22 am 
Offline
Site Admin

Joined: Sun Mar 14, 2004 3:17 pm
Posts: 4492
Location: Loveland, Colorado, USA
Code:
convert -resize 1024\>x768 foo.jpg foo-small.jpg


Or to do a whole directory, you could do a script something like:

Code:
#!/bin/sh
for i in *.jpg
do echo "converting $i"
   convert -resize 1024\>x768 \
   $i `basename $i .jpg`-small.jpg
done


Last edited by jebba on Thu Jan 03, 2008 8:37 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 02, 2008 12:53 pm 
Offline

Joined: Thu Nov 15, 2007 4:03 pm
Posts: 163
hey jebba,
where did you come up with some concoction like that? LOL

that's exactly what i'm talking about with the command line. who in their right mind, would know some gibberish like that? no, normal joe blow user would EVER figure that out!!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 02, 2008 1:43 pm 
Offline

Joined: Thu Jul 13, 2006 5:01 pm
Posts: 509
Location: Boston, MA, USA
saddletramp wrote:
that's exactly what i'm talking about with the command line. who in their right mind, would know some gibberish like that? no, normal joe blow user would EVER figure that out!!


saddletramp - for some of us normal joes, it's our job to both figure out and create command line gibberish when there's no available GUI to do the trick. Jebba's example is a fairly simple but powerful 5-line shell script that will resize every JPG file in a directory. It's the stock and trade of Joe Admin.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 02, 2008 1:43 pm 
Offline

Joined: Thu Oct 06, 2005 3:49 pm
Posts: 186
Try "apropos resize"


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 02, 2008 2:30 pm 
Offline

Joined: Thu Nov 15, 2007 4:03 pm
Posts: 163
extraspecialbitter wrote:
saddletramp wrote:
that's exactly what i'm talking about with the command line. who in their right mind, would know some gibberish like that? no, normal joe blow user would EVER figure that out!!


saddletramp - for some of us normal joes, it's our job to both figure out and create command line gibberish when there's no available GUI to do the trick. Jebba's example is a fairly simple but powerful 5-line shell script that will resize every JPG file in a directory. It's the stock and trade of Joe Admin.


i apologise for talking about it like that, but it simply blows me away. i couldn't do that "gibberish" if i wanted to, i don't think. will probably take more years to learn that i have left on earth! i have enough headaches fixing everybody else's stuff around here in the windows world, along with my real job. i'm just here to play in linux.

so, from here on in, when ever you hear me talk about the command line, just blow it off! i respect it and fear it!! but, do expect me to be asking, when necessary, what the heck is the code for whatever i may be trying to wreck!!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 02, 2008 3:41 pm 
Offline

Joined: Fri Nov 18, 2005 3:07 am
Posts: 699
saddletramp wrote:
i apologise for talking about it like that, but it simply blows me away. i couldn't do that "gibberish" if i wanted to, i don't think. will probably take more years to learn that i have left on earth! i have enough headaches fixing everybody else's stuff around here in the windows world, along with my real job. i'm just here to play in linux.

so, from here on in, when ever you hear me talk about the command line, just blow it off! i respect it and fear it!! but, do expect me to be asking, when necessary, what the heck is the code for whatever i may be trying to wreck!!


Dude, that's like saying some Asian language is gibberish just because you don't know how to read it. Once you learn the language, it makes much more sense. When you need to learn something new, you can read the documentation on how to use it.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 02, 2008 6:00 pm 
Offline

Joined: Thu Nov 15, 2007 4:03 pm
Posts: 163
"Dude, that's like saying some Asian language is gibberish just because you don't know how to read it."

Dude,
that's EXACTLY what i'm saying!! LOL


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 02, 2008 6:49 pm 
Offline
Site Admin

Joined: Sun Mar 14, 2004 3:17 pm
Posts: 4492
Location: Loveland, Colorado, USA
saddletramp wrote:
hey jebba,
where did you come up with some concoction like that? LOL

that's exactly what i'm talking about with the command line. who in their right mind, would know some gibberish like that? no, normal joe blow user would EVER figure that out!!


If you want to resize, say, five thousand images you can do it with that wee little script, hit enter and go away until it's done. Imagine trying to do that with gimp or photoshop!

Since the system is so well documented you can just type `man <command>` and read all the documentation about it. Depending on your workflow a few simple commands can really speed up what you do....

-Jeff


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 02, 2008 7:05 pm 
Offline

Joined: Thu Oct 06, 2005 3:49 pm
Posts: 186
and better than that, you don't have to wait for it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 03, 2008 7:49 am 
Offline
Site Admin

Joined: Sun Mar 14, 2004 4:45 pm
Posts: 621
Location: London
What we need is little bits like that documented Jeff :) I didn't actually know that either despite knowing a fair bit of command line work. Never crossed my mind the command line would handle images. Nice job.

Photoshop CS3 does it btw automatically saving as any file type, resolution, size, etc. Just murders your memory for like half an hour. And it isn't free and nowhere near as quick evidently.

I am going to look for a nice easy way to rip all the code out of these forums to stick somewhere either on BLAG site or wiki though my wiki skills are a bit off the mark.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 03, 2008 8:02 am 
Offline

Joined: Sun Sep 10, 2006 6:44 am
Posts: 14
Jebba, good stuff. Like all others I wish I could come up with something as smart & to the point. I never did get by head around command line scripts. One thing though, I needed to change "$i.jpg" to "$i" as the ".jpg" is already part of the extracted symbol.

Cheers


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 03, 2008 8:38 am 
Offline
Site Admin

Joined: Sun Mar 14, 2004 3:17 pm
Posts: 4492
Location: Loveland, Colorado, USA
timl wrote:
I needed to change "$i.jpg" to "$i" as the ".jpg" is already part of the extracted symbol.


ah thx for pointing that out. fixed above.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 03, 2008 10:41 am 
Offline
Site Admin

Joined: Wed Mar 17, 2004 6:17 pm
Posts: 1340
Location: London, UK
Slightly off topic but here's a script for mass renaming files by extension. Feed something like jpg and it will remove all the spaces, replacing them with foo_bar_la_de_dah.jpg"
Code:
#! /bin/bash
# -*- mode: shell -*-
# nulspaces.sh - a script to remove spaces from files
# for safety we ask for file extension before we operate
# date Sun Jan  9 02:19:14 GMT 2005
# todo
# file permissions, verbosity, confirmations, changing dirnames as well
# jayeola :*cough*: gmail :*cough*: com
# Free Software Foundation, Inc.

read -p "extension :  " EXT
find /home/$USER/ -iname "* *"$EXT"" | while read line
do
    BN=`basename "$line"  |sed -e 's/ /_/g'`
    DN=`dirname "$line"`
    mv  "$line"   "$DN"/"$BN"| sh -s
    echo "$BN" moved
done

_________________
BLAG 'em up!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 03, 2008 1:54 pm 
Offline

Joined: Thu Nov 15, 2007 4:03 pm
Posts: 163
jebba wrote:
timl wrote:
I needed to change "$i.jpg" to "$i" as the ".jpg" is already part of the extracted symbol.


ah thx for pointing that out. fixed above.


see? and as lousy a typist as i am!! to easy to make a mistake and possibly really mess something up.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group