LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-12-2010, 07:07 PM   #1
snatale1
Member
 
Registered: Aug 2003
Location: Richmond, Virginia, US
Distribution: Ubuntu 20.04 / Manjaro
Posts: 439

Rep: Reputation: 48
Gimp: Is it possible to batch strip pic quality?


I'm a field tech and daily I upload between 10-30 pics to my company, the files are huge so I open them ALL w/Gimp and re-save them but change the quality slider to 20 to reduce file size. After months of this it's getting old. Is there a way to do say, an entire dir at once? I don't care if it's with Gimp or not.
 
Old 07-12-2010, 09:04 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Maybe ImageMagik would work, I wrote this bit of perl ( on windows ) a few years back, you should be able to modify it for linux easily.

cheers

Code:
use strict;
use warnings;

##-- vars --##
my @files;
my $dir = "c:/photos";
my ( $filesize1, $filesize2, $file, $counter, $totalFiles );
my @weekDay = qw( Sunday Monday Tuesday Wednesday Thursday Friday Saturday );
my $displayDate;

##-- subs --##
sub getDate {
	my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime time;
	$mon += 1;
	$year += 1900;
	$displayDate = "$weekDay[$wday] $mday/$mon/$year $hour:$min";

}

##-- main --##
&getDate;
$counter = 0;

opendir(PHOTOS, $dir) or die "Can't open $dir: $!";
@files = grep { /\.jpg$/ } readdir(PHOTOS);
closedir ( PHOTOS );

foreach ( @files ) {
	$file = $_;
	$filesize1 = -s "$dir/$file";
	if ( $filesize1 > 1000000 ) {
		$counter++;
		system ("mogrify -resize 640x480 $dir\\$file"); 
		$filesize2 = -s "$dir/$file";
		print "\nFile: $_\n" . "old size: $filesize1\n" . "new size: $filesize2\n\n";
	}
}

open ( LOG, ">c:/temp/reduce_log.txt" );
$totalFiles = @files;
print LOG "\n\nProcessing started: $displayDate\n";
&getDate;
print LOG "Processing completed: $displayDate\n\n";
print LOG "Files in directory: $totalFiles\n";
print LOG "Files resized: $counter\n";
close ( LOG );
 
Old 07-12-2010, 10:22 PM   #3
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
are these lousy jpg's or lossless png's ( i am assuming the losley jpg)

i would first look into if you NEED the detail that is forever lost in a very compressed jpg
and if you do use *.png instead .

also imagemagick's " convert" will do a batch and so will " mogrify "
mogrify is designed for batch work.
 
Old 07-12-2010, 10:24 PM   #4
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
You could try this gimp plugin. Or write your own script.

Last edited by smoker; 07-12-2010 at 10:27 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Gimp batch mode! experienced an execution error. Shioni Linux - Software 0 04-21-2006 06:41 AM
Need help doing batch-convert with Gimp paulsm4 Linux - Software 0 01-09-2006 01:11 AM
Gimp does not respect cups quality soulfire Linux - Software 2 01-02-2006 10:34 AM
Why cant I save a pic after changing it in gimp, permissions problem? M$ISBS Linux - Software 3 08-08-2005 12:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration