Convert JPEG from 72 dpi to 300 dpi

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, xnview

jmann
Posts: 4
Joined: Thu Jul 07, 2016 5:00 pm

Convert JPEG from 72 dpi to 300 dpi

Postby jmann » Thu Jul 07, 2016 5:06 pm

I've used ... -out jpeg -dpi 300 -keepdocsize -keepfiledate -overwrite -no_auto_ext ... to update my test image with success, kind of. I don't see an command to use with -keepdocsize that would keep the original size. When I convert my image from 6000x4000 72dpi it becomes 25000x16667 300dpi. What am I missing?

User avatar
XnTriq
Moderator & Librarian
Posts: 4869
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Convert JPEG from 72 dpi to 300 dpi

Postby XnTriq » Thu Jul 07, 2016 7:30 pm

Welcome to the forum, jmann.

xnview (JPEG to CMYK conversion issue?) wrote:-dpi is only used for pdf, if you want to resize your picture use

Code: Select all

-resize

User avatar
XnTriq
Moderator & Librarian
Posts: 4869
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Convert JPEG from 72 dpi to 300 dpi

Postby XnTriq » Thu Jul 07, 2016 8:30 pm

If I'm not mistaken, there's more than one way to store the DPI in JPEGs.
Are you looking for a lossless way (i.e. without recompression) to set or change the DPI?


jmann
Posts: 4
Joined: Thu Jul 07, 2016 5:00 pm

Re: Convert JPEG from 72 dpi to 300 dpi

Postby jmann » Fri Jul 08, 2016 2:16 pm

In the Windows GUI when resizing an image there are multiple options but specifically one to change the DPI and a checkbox for Resample with a select box for types (ex. Lanczos). I want to be able to do this with nConvert command line. Currently I can successfully change the DPI to 300 using:

-out jpeg -dpi 300 -keepdocsize -keepfiledate -overwrite -no_auto_ext

However the file become massive going from 6mb to 16mb. If I exclude -keepdocsize from this command line then the file becomes 1.8mb. How do I keep the actual 6mb file size. I can do this in Photoshop but that isn't a batch solution I would use.

User avatar
XnTriq
Moderator & Librarian
Posts: 4869
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Convert JPEG from 72 dpi to 300 dpi

Postby XnTriq » Fri Jul 08, 2016 3:00 pm

NConvert defaults to a JPEG compression factor of 85.
XnView OTOH uses the settings provided in Tools » Options... » Read/Write » Write » JPEG.
The option to Use estimated original quality if possible is not available nConvert, AFAIK.

What are the specs (Q-factor, sub-sampling, metadata, etc.) of your input files?

jmann
Posts: 4
Joined: Thu Jul 07, 2016 5:00 pm

Re: Convert JPEG from 72 dpi to 300 dpi

Postby jmann » Mon Jul 11, 2016 5:50 pm

I'm not sure what the q-factor is. Quality of the images are 100% from the camera and sub-sampling should be 2. I've adjusted the command line to:

-out jpeg -dpi 300 -subsampling 2 -overwrite -no_auto_ext

Now my test file instead of 1.84 MB is 2.28 MB which is closer to the 6.09 MB of the original file size. Meta data is attached but I'm not sure what else if anything I can adjust on the command line to keep the original file size. Going from 6.09 MB to 2.28 MB makes me believe there has to be some kind of quality loss but if I add -q 100 to the command line the file size goes up to 10 MB.
Attachments
updated-meta.png
updated-meta.png (29.36 KiB) Viewed 973 times
original-meta.png
original-meta.png (33.86 KiB) Viewed 973 times

User avatar
XnTriq
Moderator & Librarian
Posts: 4869
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Convert JPEG from 72 dpi to 300 dpi

Postby XnTriq » Mon Jul 11, 2016 7:45 pm

jmann wrote:I'm not sure what the q-factor is.

I'm referring to the quality/compression factor.

I dug up a few unedited samples (6000×4000 pixels) shot with an EOS Rebel T6i.
According to JPEGsnoop, the specifications are as follows:

  • Canon.Cs1.Quality = norm
    Canon.Cs1.ImageSize = Large
    • Approx quality factor: 90
    • Chroma subsampling: 2x1 ~ 2×1,1×1,1×1 ~ 4:2:2
  • Canon.Cs1.Quality = fine
    Canon.Cs1.ImageSize = Large
    • Approx quality factor: 97
    • Chroma subsampling: 2x1 ~ 2×1,1×1,1×1 ~ 4:2:2
Which setting (“Normal”/“Fine”) do you use?

nConvert wrote:

Code: Select all

          -q value          : JPEG/FPX/WIC/PDF quality (default : 85)
          -subsampling value : Subsampling factor
              0  : 2x2,1x1,1x1
              1  : 2x1,1x1,1x1
              2  : 1x1,1x1,1x1

jmann
Posts: 4
Joined: Thu Jul 07, 2016 5:00 pm

Re: Convert JPEG from 72 dpi to 300 dpi

Postby jmann » Mon Jul 11, 2016 9:15 pm

Okay I tried using this command ...

-out jpeg -dpi 300 -subsampling 2 -q 96 -overwrite -no_auto_ext

This gets me to just about the original file size. For the quality setting though ... what is the real difference from -q 85 as default at 2 MB to -q 96 at 6 MB. If related to an option in Photoshop when editing an image ... what would be related?
Attachments
camera-settings.jpg
Camera settings we use
camera-settings.jpg (35.79 KiB) Viewed 963 times

User avatar
XnTriq
Moderator & Librarian
Posts: 4869
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Convert JPEG from 72 dpi to 300 dpi

Postby XnTriq » Mon Jul 11, 2016 11:15 pm

jmann wrote:For the quality setting though ... what is the real difference from -q 85 as default at 2 MB to -q 96 at 6 MB.

This is typical for JPEG compression: file size increases disproportionately to image quality beyond a factor of 75 or 80, IOW file size grows exponentially as quality improves.

These are results of my test with T6IhHOUSE.JPG (13'099'210 bytes):

  •   6'223'313 bytes | -out jpeg -dpi 300 -subsampling 2 -q 85 -overwrite -no_auto_ext
  • 13'272'757 bytes | -out jpeg -dpi 300 -subsampling 2 -q 96 -overwrite -no_auto_ext
BTW: The option -subsampling 2 tells nConvert to use no chroma sub-sampling (1×1,1×1,1×1 ~ 4:4:4), resulting in a larger file size.

jmann wrote:If related to an option in Photoshop when editing an image ... what would be related?

Apparently, there's no exact match in Photoshop for Canon's “Large/Fine” (Q97 @ 2×1) compression scheme :-|

ImpulseAdventure (JPEG Chroma Subsampling » Photoshop Quality and subsampling) wrote:
As an aside, note that Photoshop CS2 uses different chroma subsampling levels depending on the Save JPEG Quality settings:

  • Photoshop Save As Quality 0-6 - 2x2 Chroma Subsampling
  • Photoshop Save As Quality 7-12 - 1x1 No Chroma Subsampling
  • Photoshop Save For Web Quality 0-50 - 2x2 Chroma Subsampling
  • Photoshop Save For Web Quality 51-100 - 1x1 No Chroma Subsampling


User avatar
XnTriq
Moderator & Librarian
Posts: 4869
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Convert JPEG from 72 dpi to 300 dpi

Postby XnTriq » Mon Jul 11, 2016 11:45 pm

@Pierre: Do you have any recommendations for changing the DPI values in JPEGs as losslessly as possible?

User avatar
xnview
Author of XnView
Posts: 27088
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Convert JPEG from 72 dpi to 300 dpi

Postby xnview » Tue Jul 12, 2016 11:11 am

XnTriq wrote:@Pierre: Do you have any recommendations for changing the DPI values in JPEGs as losslessly as possible?

without recompressing, no
Pierre.


Return to “NConvert”

Who is online

Users browsing this forum: No registered users and 1 guest