codingCat
Posts: 30
Joined: Tue Jul 09, 2013 4:49 am

Image Size Too Big

Wed Mar 26, 2014 10:46 pm

Using RaspiStill to take a picture with JPG encoding I am getting a file that is over two megs. When I reduce the quality down to 50% the file size of the picture taken only drops the file size by about 200K, or less then a ten percent decrease. When I take that original 2 meg+ file and save it through Paint.Net with the quality set at 85 percent it drops the file size down to 300k, or almost a 90% decrease.

Am I doing something wrong, or is there something wrong with the encoder in RaspiStill?

Below is command line that I use to take the picture:
[email protected] ~/Development/tests $ raspistill -n -t 100 -q 50 -e jpg -o fullsizejpgsethalfquality.jpg

Resulting File Size: 2052kb
Resaving the same file though Paint.Net at 85% quality: 319kb

Thoughts?

User avatar
GTR2Fan
Posts: 1601
Joined: Sun Feb 23, 2014 9:20 pm
Location: South East UK

Re: Image Size Too Big

Wed Mar 26, 2014 11:54 pm

Out of interest, what size file do you end up with if you use -q 15 with RaspiStill? Does it turn out to be roughly the same as Paint.Net at 85%?
Pi2B Mini-PC/Media Centre: ARM=1GHz (+3), Core=500MHz, v3d=500MHz, h264=333MHz, RAM=DDR2-1200 (+6/+4/+4+schmoo). Sandisk Ultra HC-I 32GB microSD card on '50=100' OCed slot (42MB/s read) running Raspbian/KODI16, Seagate 3.5" 1.5TB HDD mass storage.

codingCat
Posts: 30
Joined: Tue Jul 09, 2013 4:49 am

Re: Image Size Too Big

Thu Mar 27, 2014 1:04 am

GTR2Fan wrote:Out of interest, what size file do you end up with if you use -q 15 with RaspiStill? Does it turn out to be roughly the same as Paint.Net at 85%?
As you decrease the quality, the size decrease by about 10% for each 20% of quality decrease. The file size drops to about 50% when you get down to about 5% quality. The image itself is blocky and almost unrecognizable. None of this matches the decreases and quality you get with normal jpeg compression.

Oh, and for the record apt-get update and upgrade with no effect on the outcome.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 20697
Joined: Sat Jul 30, 2011 7:41 pm

Re: Image Size Too Big

Thu Mar 27, 2014 8:52 am

codingCat wrote:
GTR2Fan wrote:Out of interest, what size file do you end up with if you use -q 15 with RaspiStill? Does it turn out to be roughly the same as Paint.Net at 85%?
As you decrease the quality, the size decrease by about 10% for each 20% of quality decrease. The file size drops to about 50% when you get down to about 5% quality. The image itself is blocky and almost unrecognizable. None of this matches the decreases and quality you get with normal jpeg compression.

Oh, and for the record apt-get update and upgrade with no effect on the outcome.
The thing is, there is no 'normal' jpeg compression. Most implementations handle 'quality' in a different way , so Q50 on one system in all likelihood won't match Q50 on another system.

Just try numbers until you get what you want.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5798
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Image Size Too Big

Thu Mar 27, 2014 9:12 am

Quality factor != percentage. http://photo.net/learn/jpeg/#qual has a reasonable explanation.

I do vaguely recall that our default is not the IJG quantisation tables, but i can't remember what is used instead. I would have expected a bigger change than 200kB when dropping to q=50.
As Jamesh says, q factor can rarely be compared accurately from one app to another. Find a number that give you the file size and compression ratio that you want in your chosen app.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

mikerr
Posts: 2728
Joined: Thu Jan 12, 2012 12:46 pm
Location: UK
Contact: Website

Re: Image Size Too Big

Thu Mar 27, 2014 12:42 pm

Using raspistill -q parameter in increments of 5 :

Code: Select all

raspistill -q 5 -o image05.jpg

Code: Select all

 ls -lh image*
-rw-r--r-- 1 pi pi 249K Mar 27 12:30 image05.jpg
-rw-r--r-- 1 pi pi 522K Mar 27 12:32 image10.jpg
-rw-r--r-- 1 pi pi 863K Mar 27 12:33 image15.jpg
-rw-r--r-- 1 pi pi 1.2M Mar 27 12:33 image20.jpg
-rw-r--r-- 1 pi pi 1.6M Mar 27 12:33 image25.jpg
-rw-r--r-- 1 pi pi 1.9M Mar 27 12:34 image30.jpg
-rw-r--r-- 1 pi pi 2.1M Mar 27 12:34 image35.jpg
-rw-r--r-- 1 pi pi 2.2M Mar 27 12:34 image40.jpg
-rw-r--r-- 1 pi pi 2.5M Mar 27 12:34 image45.jpg
-rw-r--r-- 1 pi pi 2.6M Mar 27 12:34 image50.jpg
-rw-r--r-- 1 pi pi 2.7M Mar 27 12:35 image55.jpg
-rw-r--r-- 1 pi pi 3.0M Mar 27 12:35 image60.jpg
-rw-r--r-- 1 pi pi 3.0M Mar 27 12:35 image65.jpg
-rw-r--r-- 1 pi pi 3.0M Mar 27 12:35 image70.jpg
-rw-r--r-- 1 pi pi 3.0M Mar 27 12:35 image75.jpg
-rw-r--r-- 1 pi pi 3.0M Mar 27 12:35 image80.jpg
-rw-r--r-- 1 pi pi 3.0M Mar 27 12:36 image85.jpg
-rw-r--r-- 1 pi pi 3.0M Mar 27 12:36 image90.jpg
-rw-r--r-- 1 pi pi 3.0M Mar 27 12:36 image95.jpg
-rw-r--r-- 1 pi pi 3.0M Mar 27 12:30 image.jpg
You can check the quality live in my android app in my sig (put "-q 10" in commandline settings)
interesting that things still seem ok (but not great) visually down at q10/15, q5 degrades badly (but I've seen worse webcams !)

Only at q1 and q2 does it go into a blocky mess:
Image
http://imgur.com/a/vQEer
Last edited by mikerr on Thu Mar 27, 2014 1:56 pm, edited 3 times in total.
Android app - Raspi Card Imager - download and image SD cards - No PC required !

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5798
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Image Size Too Big

Thu Mar 27, 2014 1:52 pm

Just done a quick comparison of the official IJG quantisation tables against our default ones. Comparing against mikerr's file sizes (top), you can see there aren't any significant differences vs IJG (bottom).
Default_vs_IJG.jpg
Default_vs_IJG.jpg (63.48 KiB) Viewed 7215 times
As my camera isn't on a mount, my scene may have changed slightly between shots hence my graph isn't totally smooth, and Mikerr's numbers dropped to 2sig.figs for the top results producing an artificially flat line.

Based on that, I see no point in pursuing this further - there is very little difference between the two sets of tables, and users just need to be aware that the quality setting is not a percentage compression ratio.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

ethanol100
Posts: 540
Joined: Wed Oct 02, 2013 12:28 pm

Re: Image Size Too Big

Thu Mar 27, 2014 1:57 pm

Can you use imagemagick's indentify to get the quality for your different q values?

If you use

Code: Select all

identify -verbose image.jpg
you find the value "Quality: " which should correspond approximately to the quality definition used by gimp and other tools. Would be interesting to plot your q values against this Quality values. It seems that, i.e., -q 20 correspond to Quality=75 in imagemagick.

mikerr
Posts: 2728
Joined: Thu Jan 12, 2012 12:46 pm
Location: UK
Contact: Website

Re: Image Size Too Big

Thu Mar 27, 2014 2:44 pm

Here's the output of imagemagick for raspistill -q 20

Code: Select all

identify -verbose imageq20.jpg
Image: imageq20.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Class: DirectClass
  Geometry: 2592x1944+0+0
  Resolution: 72x72
  Print size: 36x27
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 142 (0.556864)
      standard deviation: 56.8174 (0.222813)
      kurtosis: -0.533636
      skewness: -0.526224
    Green:
      min: 4 (0.0156863)
      max: 255 (1)
      mean: 118.397 (0.464302)
      standard deviation: 49.4015 (0.193731)
      kurtosis: -0.708864
      skewness: -0.409558
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 127.194 (0.4988)
      standard deviation: 48.2314 (0.189143)
      kurtosis: -0.671426
      skewness: -0.47026
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 129.197 (0.506655)
      standard deviation: 51.6236 (0.202445)
      kurtosis: -0.44011
      skewness: -0.404349
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Interlace: None
  Background color: white
  Border color: srgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Compose: Over
  Page geometry: 2592x1944+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 94
  Orientation: Undefined
  Properties:
    date:create: 2014-03-27T14:38:16+00:00
    date:modify: 2014-03-27T14:38:16+00:00
    exif:ApertureValue: 30705/10000
    exif:BrightnessValue: 303/100
    exif:ColorSpace: 1
    exif:ComponentsConfiguration: 1, 2, 3, 0
    exif:Compression: 6
    exif:DateTime: 2014:03:27 14:38:15
    exif:DateTimeDigitized: 2014:03:27 14:38:15
    exif:DateTimeOriginal: 2014:03:27 14:38:15
    exif:ExifImageLength: 1944
    exif:ExifImageWidth: 2592
    exif:ExifOffset: 192
    exif:ExifVersion: 48, 50, 50, 48
    exif:ExposureMode: 0
    exif:ExposureProgram: 3
    exif:ExposureTime: 61515/1000000
    exif:Flash: 0
    exif:FlashPixVersion: 48, 49, 48, 48
    exif:FNumber: 28984/10000
    exif:FocalLength: 35976/10000
    exif:ImageLength: 1944
    exif:ImageWidth: 2592
    exif:InteroperabilityIndex: R98
    exif:InteroperabilityOffset: 906
    exif:ISOSpeedRatings: 160
    exif:JPEGInterchangeFormat: 1042
    exif:JPEGInterchangeFormatLength: 24576
    exif:Make: RaspberryPi
    exif:MakerNote: 101, 118, 61, 45, 49, 32, 109, 108, 117, 120, 61, 45, 49, 32, 101, 120, 112, 61, 54, 49, 53, 49, 53, 32, 97, 103, 61, 51, 56, 52, 32, 102, 111, 99, 117, 115, 61, 50, 53, 53, 32, 103, 97, 105, 110, 95, 114, 61, 49, 46, 48, 48, 51, 32, 103, 97, 105, 110, 95, 98, 61, 49, 46, 53, 51, 49, 32, 103, 114, 101, 101, 110, 110, 101, 115, 115, 61, 45, 53, 52, 32, 99, 99, 109, 61, 56, 55, 49, 52, 44, 45, 51, 56, 53, 52, 44, 45, 55, 53, 56, 44, 45, 49, 54, 48, 50, 44, 54, 51, 48, 54, 44, 45, 54, 48, 52, 44, 52, 57, 54, 44, 45, 52, 49, 56, 52, 44, 55, 55, 57, 52, 44, 48, 44, 48, 44, 48, 32, 109, 100, 61, 48, 32, 116, 103, 61, 50, 50, 52, 32, 50, 50, 52, 32, 111, 116, 104, 61, 48, 32, 48, 32, 98, 61, 48, 32, 102, 61, 50, 50, 52, 32, 50, 50, 52, 32, 102, 105, 61, 48, 32, 73, 83, 80, 32, 66, 117, 105, 108, 100, 32, 68, 97, 116, 101, 58, 32, 77, 97, 114, 32, 49, 53, 32, 50, 48, 49, 52, 44, 32, 49, 53, 58, 50, 57, 58, 50, 49, 32, 86, 67, 95, 66, 85, 73, 76, 68, 95, 73, 68, 95, 86, 69, 82, 83, 73, 79, 78, 58, 32, 98, 57, 48, 48, 99, 52, 100, 56, 98, 52, 53, 50, 97, 57, 99, 102, 53, 56, 57, 55, 50, 102, 55, 97, 98, 98, 55, 48, 99, 54, 102, 101, 52, 51, 54, 56, 99, 53, 100, 97, 32, 40, 99, 108, 101, 97, 110, 41, 32, 86, 67, 95, 66, 85, 73, 76, 68, 95, 73, 68, 95, 85, 83, 69, 82, 58, 32, 100, 99, 52, 32, 86, 67, 95, 66, 85, 73, 76, 68, 95, 73, 68, 95, 66, 82, 65, 78, 67, 72, 58, 32, 100, 101, 118, 32
    exif:MaxApertureValue: 30705/10000
    exif:MeteringMode: 2
    exif:Model: RP_OV5647
    exif:ResolutionUnit: 2
    exif:ShutterSpeedValue: 4022918/1000000
    exif:WhiteBalance: 0
    exif:XResolution: 72/1
    exif:YCbCrPositioning: 1
    exif:YResolution: 72/1
    jpeg:colorspace: 2
    jpeg:sampling-factor: 2x2,1x1,1x1
    signature: 00b6a67eb6e69f3945d51652c248e302777dc2da41a9cadee73d70c03f0204df
  Profiles:
    Profile-exif: 25624 bytes
  Artifacts:
    filename: imageq20.jpg
    verbose: true
  Tainted: False
  Filesize: 1.425MB
  Number pixels: 5.039M
  Pixels per second: 2.739MB
  User time: 1.820u
  Elapsed time: 0:02.840
  Version: ImageMagick 6.7.7-10 2013-09-03 Q16 http://www.imagemagick.org
i.e. Quality: 94

or just the Quality: lines for the other q settings:

Code: Select all

-rw-r--r-- 1 pi pi 112K Mar 27 14:38 imageq1.jpg
  Quality: 1
-rw-r--r-- 1 pi pi 119K Mar 27 14:38 imageq2.jpg
  Quality: 4
-rw-r--r-- 1 pi pi 286K Mar 27 14:38 imageq5.jpg
  Quality: 25
-rw-r--r-- 1 pi pi 628K Mar 27 14:38 imageq10.jpg
  Quality: 75
-rw-r--r-- 1 pi pi 1019K Mar 27 14:38 imageq15.jpg
  Quality: 90
-rw-r--r-- 1 pi pi 1.4M Mar 27 14:38 imageq20.jpg
  Quality: 94
-rw-r--r-- 1 pi pi 1.9M Mar 27 14:38 imageq25.jpg
  Quality: 97
-rw-r--r-- 1 pi pi 2.2M Mar 27 14:38 imageq30.jpg
  Quality: 98
-rw-r--r-- 1 pi pi 2.4M Mar 27 14:38 imageq35.jpg
  Quality: 98
-rw-r--r-- 1 pi pi 2.6M Mar 27 14:38 imageq40.jpg
  Quality: 99
-rw-r--r-- 1 pi pi 2.9M Mar 27 14:38 imageq45.jpg
  Quality: 99
-rw-r--r-- 1 pi pi 2.9M Mar 27 14:38 imageq50.jpg
  Quality: 99
-rw-r--r-- 1 pi pi 3.0M Mar 27 14:38 imageq55.jpg
  Quality: 99
-rw-r--r-- 1 pi pi 3.4M Mar 27 14:38 imageq60.jpg
  Quality: 100
-rw-r--r-- 1 pi pi 3.4M Mar 27 14:38 imageq65.jpg
  Quality: 100
-rw-r--r-- 1 pi pi 3.4M Mar 27 14:38 imageq70.jpg
  Quality: 100
-rw-r--r-- 1 pi pi 3.4M Mar 27 14:38 imageq75.jpg
  Quality: 100
-rw-r--r-- 1 pi pi 3.4M Mar 27 14:38 imageq80.jpg
  Quality: 100
-rw-r--r-- 1 pi pi 3.4M Mar 27 14:38 imageq85.jpg
  Quality: 100
-rw-r--r-- 1 pi pi 3.4M Mar 27 14:38 imageq90.jpg
  Quality: 100
-rw-r--r-- 1 pi pi 3.4M Mar 27 14:38 imageq95.jpg
  Quality: 100
-rw-r--r-- 1 pi pi 3.4M Mar 27 14:38 imageq100.jpg
  Quality: 100

and two big galleries to squint at, this time using the regular pi camera as well as pi noir :

Pi Noir
http://imgur.com/a/RgWHr
Regular pi camera:
Image
http://imgur.com/a/vqxfx
Android app - Raspi Card Imager - download and image SD cards - No PC required !

ethanol100
Posts: 540
Joined: Wed Oct 02, 2013 12:28 pm

Re: Image Size Too Big

Thu Mar 27, 2014 4:53 pm

Thanks for the quality values. I have tried to fill some values with my camera.
q_vs_quality.jpg
q_vs_quality.jpg (51.21 KiB) Viewed 7133 times
So we can adjust the high quality values very fine. But need to go down to small "-q" values for high compression. That's ok for me.

codingCat
Posts: 30
Joined: Tue Jul 09, 2013 4:49 am

Re: Image Size Too Big

Fri Mar 28, 2014 3:56 am

Well, that's more than a little insane. Why make the quality values logarithmic-esk?

This would explain how there was no detectable change in value until it seem to drop off a cliff when the quality value got down to 5. That's because it was falling off a cliff.

I ran the tests again -- consistent lighting with an uncomplicated picture (camera pointed at window blinds). With a VGA size picture the change from quality 100 to 10 was about 75% drop (from 170k to 41k) with very little change in apparent quality. From there each drop in number was a serious drop in quality with little change in size (from 40k at quality 9 to 31k at quality 1).

Even with this knowledge, this still represents poor performance for Jpeg compression. Testing with several other utilities (including on that uses the same C-Library advertised to be used by Raspistill) I consistently saw a drop to under 15K for the same image with very little degrade in quality.

While still an irritant, at least now I know how it works. The logarithmic-esk values do not provide for fine-tuning, so I think some post processing will be required as keeping the file size down is vital to this particular project -- a remote weather station connect via a 56kb radio modem.

Thanks to ethanol100 for the information. At least I know what I am dealing with now -- the graph was particularly useful. :-)

ethanol100
Posts: 540
Joined: Wed Oct 02, 2013 12:28 pm

Re: Image Size Too Big

Fri Mar 28, 2014 7:09 am

Have you tried to disable the thumbnail image(-th 0:0:0, not sure about that.)? This should be a relative big part of your file size at low resolution and high compression.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 20697
Joined: Sat Jul 30, 2011 7:41 pm

Re: Image Size Too Big

Fri Mar 28, 2014 8:22 am

codingCat wrote:Well, that's more than a little insane. Why make the quality values logarithmic-esk?

This would explain how there was no detectable change in value until it seem to drop off a cliff when the quality value got down to 5. That's because it was falling off a cliff.

I ran the tests again -- consistent lighting with an uncomplicated picture (camera pointed at window blinds). With a VGA size picture the change from quality 100 to 10 was about 75% drop (from 170k to 41k) with very little change in apparent quality. From there each drop in number was a serious drop in quality with little change in size (from 40k at quality 9 to 31k at quality 1).

Even with this knowledge, this still represents poor performance for Jpeg compression. Testing with several other utilities (including on that uses the same C-Library advertised to be used by Raspistill) I consistently saw a drop to under 15K for the same image with very little degrade in quality.

While still an irritant, at least now I know how it works. The logarithmic-esk values do not provide for fine-tuning, so I think some post processing will be required as keeping the file size down is vital to this particular project -- a remote weather station connect via a 56kb radio modem.

Thanks to ethanol100 for the information. At least I know what I am dealing with now -- the graph was particularly useful. :-)
Insane? The graph matches the standard Independent JPEG Groups quantisation tables, so in that case they must also be insane. As above, turn off thumbnails.

I think the quantisation tables can be changed, but the encoder itself in a HW block, so that isn't going to change!
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

mikerr
Posts: 2728
Joined: Thu Jan 12, 2012 12:46 pm
Location: UK
Contact: Website

Re: Image Size Too Big

Fri Mar 28, 2014 10:05 am

codingCat wrote: I ran the tests again -- consistent lighting with an uncomplicated picture (camera pointed at window blinds). With a VGA size picture the change from quality 100 to 10 was about 75% drop (from 170k to 41k) with very little change in apparent quality. From there each drop in number was a serious drop in quality with little change in size (from 40k at quality 9 to 31k at quality 1).
Disabling the thumbnail cuts the filesize in half at VGA frame sizes:

Code: Select all

raspistill  -th none 

Code: Select all

-rw-r--r-- 1 pi   pi    46K Mar 28 10:00 image640-q5.jpg
-rw-r--r-- 1 pi   pi    21K Mar 28 10:00 image640-q5-nothumb.jpg

-rw-r--r-- 1 pi   pi    74K Mar 28 10:06 image640-q10.jpg
-rw-r--r-- 1 pi   pi    49K Mar 28 10:07 image640-q10-nothumb.jpg
You could get an uncompressed BMP out of the raspicam, and compress it to jpeg with other tools (imagemagick)

Code: Select all

raspistill -t 500 -w 640 -h 480 -e bmp -o image640.bmp
convert -quality 75 image640.bmp image640.jpg
this method also has the advantage of being able to add text info to the image before the compression is applied:

Code: Select all

convert -quality 75 -annotate +30+10 "$(date)" image640.bmp image640.jpg
Android app - Raspi Card Imager - download and image SD cards - No PC required !

codingCat
Posts: 30
Joined: Tue Jul 09, 2013 4:49 am

Re: Image Size Too Big

Fri Mar 28, 2014 8:27 pm

jamesh wrote:
codingCat wrote:Well, that's more than a little insane. Why make the quality values logarithmic-esk?
Insane? The graph matches the standard Independent JPEG Groups quantisation tables, so in that case they must also be insane. As above, turn off thumbnails.
No, its not a match. Its not even close. The graph posted by 6by9 above shows a 45degree angle until it gets towards the top of the graph. You could argue that this is the same data spread out over a greater range, but that is actually my point. Compression and Quality loss is insignificant until you are down to quality value of 10. This leaves almost no granularity, no room for adjustment.

codingCat
Posts: 30
Joined: Tue Jul 09, 2013 4:49 am

Re: Image Size Too Big

Fri Mar 28, 2014 8:33 pm

Turning off the thumbnail was the last piece of the puzzle:

[email protected] ~/Development/tests $ raspistill -w 640 -h 480 -n -t 100 -q 10 -e jpg -th none -o vgasize10nothumb.jpg

The original file at quality 100 was 170k. Bringing down to quality 10 dropped the size to 40k. Turning off the thumbnail at quality 10 dropped the size down to 20k... which is what you would expect from a Jpeg with a quality setting of 85.

My thanks to mikerr and ethanol100 for the thumb nail suggestion.

ethanol100
Posts: 540
Joined: Wed Oct 02, 2013 12:28 pm

Re: Image Size Too Big

Fri Mar 28, 2014 9:25 pm

Just want to add a link: http://www.impulseadventure.com/photo/jpeg-quality.html

The raspberrypi cam is more a "digital camera" than a usb webcam. So we need to compare it to i.e. a Canon EOS camera, these will usually have only 2 possible compression levels, i.e. fine and normal, fine will correspont to some value >98. The average user will use high quality jpeg for stills. For video and streaming the more advanced h264 codec gives a better way to specify bitrate.

What application do you have in mind? Why do you need these low quality jpegs?

codingCat
Posts: 30
Joined: Tue Jul 09, 2013 4:49 am

Re: Image Size Too Big

Sat Mar 29, 2014 3:39 am

I don't need low quality images, I need small ones. I am creating a weather station with temperature, humidity, atmospheric pressure sampled every second, and a picture taken periodically. All of this information has to stream live via a 56kb radio modem. I don't want to interrupt the live data stream for more than 30 seconds at a time, so I need a really small file. A two meg (aprox. what you get from the default camera settings) will take six minutes to transmit under ideal settings (5k per second). With the nature of the radio modems a file that big in a real world environment will take almost half an hour to transmit. With the file squished down to 20k, worst case will only take three minutes to transmit, with very little trade off in quality.

Again, the magic of Jpegs. :-)

ethanol100
Posts: 540
Joined: Wed Oct 02, 2013 12:28 pm

Re: Image Size Too Big

Mon Mar 31, 2014 2:33 pm

Ok, that is a nice project. So some hints to get even smaller file sizes:

You need to have minimal noise for an effective jpeg compression. Use the lowest possible ISO value: -ISO 100
You can disable exif informations, if not needed: -x none
And you should increase the -t value, 0.1 sec is small for a good camera calibration: -t 1000

With, i.e., "raspistill -ISO 100 -w 640 -h 480 -th none -x none -q 10 -o test.jpg" test.jpg has only a size of 16k.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 20697
Joined: Sat Jul 30, 2011 7:41 pm

Re: Image Size Too Big

Mon Mar 31, 2014 6:43 pm

codingCat wrote:I don't need low quality images, I need small ones. I am creating a weather station with temperature, humidity, atmospheric pressure sampled every second, and a picture taken periodically. All of this information has to stream live via a 56kb radio modem. I don't want to interrupt the live data stream for more than 30 seconds at a time, so I need a really small file. A two meg (aprox. what you get from the default camera settings) will take six minutes to transmit under ideal settings (5k per second). With the nature of the radio modems a file that big in a real world environment will take almost half an hour to transmit. With the file squished down to 20k, worst case will only take three minutes to transmit, with very little trade off in quality.

Again, the magic of Jpegs. :-)
Low size will generally mean low quality -there is most certainly a tradeoff. If we could get high quality and low size, everyone would use it. There are mechanisms to getting better compression and *apparently* the same quality, but there is always a tradeoff.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

Deadgost
Posts: 1
Joined: Thu Oct 18, 2018 6:56 am

Re: Image Size Too Big

Thu Oct 18, 2018 7:18 am

Ya , can you give a same solution for video

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5798
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Image Size Too Big

Thu Oct 18, 2018 10:14 am

Deadgost wrote:
Thu Oct 18, 2018 7:18 am
Ya , can you give a same solution for video
??
For video (via raspivid) you specify the bitrate desired and the codec should adjust whatever parameters it has to try and achieve the best quality at that bitrate. -b option.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Camera board”