LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-18-2009, 07:51 AM   #1
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,561

Rep: Reputation: 57
Bash: How to convert whatever size pnm file to a jpg of 2.0mb ?


Bash: How to convert whatever size pnm file to a jpg of a fixe size of 2.0mb ?
 
Old 01-18-2009, 08:27 AM   #2
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Is this homework ? What purpose could this serve, other than to amuse a teacher.
 
Old 01-18-2009, 08:54 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by H_TeXMeX_H View Post
Is this homework ?
From frenchnoob---I don't think so. But you got the real question right: Why??

I think that the intent here is to convert format and make the file smaller. I was surprised to find out that you can specify the target pixel count.....

http://www.imagemagick.org/Usage/resize/#resize

My simple mind continues to be boggled by what ImageMagick can do.
 
Old 01-18-2009, 01:26 PM   #4
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,561

Original Poster
Rep: Reputation: 57
Quote:
Originally Posted by pixellany View Post
From frenchnoob---I don't think so. But you got the real question right: Why??
H_TeXMeX_H was right ...
Frenchn00b is a geek, real one, that talks badly english..
even he's making progresses in linux with trying hard all kind of things with linux.

So I found those ways:
- convert/imagemagick
man convert
gives -resize geometry
but we can screw up the shapes of the pic
beware because it can after the quality of the pic... not so perfect always... still fighting
Quote:
convert dragon.gif -resize 50% half_dragon.gif
... still looking

Last edited by frenchn00b; 01-18-2009 at 01:27 PM.
 
Old 01-18-2009, 01:30 PM   #5
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,561

Original Poster
Rep: Reputation: 57
well wont be easy to calculate the ratio of reduction, ...

Quote:
convert -resize 50% einladung-page01.pnm einladung-page01.jpg

ls -ltra einladung-page01.jpg -h
2.3M 2009-01-18 20:26 einladung-page01.jpg

ls -ltra einladung-page01.pnm -h
79M 2009-01-18 14:03 einladung-page01.pnm
pffff

79MB x 50 /100 = 2.3 Mb
 
Old 01-18-2009, 02:45 PM   #6
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
I think I see what you are trying to do now, you're trying to scale down a picture to be under 2 MB right ? or does it have to be exactly 2 MB in size ?

Indeed you would need to try to calculate the size of the file with respect to the pixel count. So, take several files and see what size they have, then divide it by the pixel count = width x height. You'll get an estimate of bytes per pixel ... I'm not sure how jpeg compression works, but this may not be the same for every picture. It may just turn out to be 24 or 32, who knows.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
convert PNM to PDF in Debian etch? bezdomny Linux - Software 2 07-31-2007 02:46 PM
HELP! BASH - Convert filenames from dsc00***.jpg to *.jpg jimmybond01 Programming 9 05-08-2007 06:17 AM
jpg file lowercase with fixed size Whynot Linux - Software 5 12-13-2006 12:36 AM
.pnm file converter gbowden Linux - Software 1 12-08-2006 11:00 PM
convert wmv to pnm/jpg in linux LexMillian Linux - Software 3 09-12-2005 06:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:28 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