BrowserUk has already said it, but for a computer, the specification "300dpi" by itself is useless, because it only tells us what density you want to print at. For it to be useful for the computer, you need to say something like "3000x2000 pixels printed at 300dpi" (which will result in a print of roughly 25.4x16.9cm), or "10x20cm at 300dpi", which is an image of 1181x2362 pixels. That same 1181x2362 pixel image can also be printed at 600dpi, in which case it will be 5x10cm, or at 150dpi, in which case it will be 20x40cm.
Anyway, maybe what you are asking about is the DPI information stored as part of the image headers. I have had success in changing it using Image::ExifTool, at least this changes the image's DPI reported by The Gimp.
use Image::ExifTool;
my $DPI = 300;
my $exif = Image::ExifTool->new;
$exif->SetNewValue("XResolution",$DPI);
$exif->SetNewValue("YResolution",$DPI);
$exif->SetNewValue("ResolutionUnit","inches");
$exif->WriteInfo($FILE)
or warn "Failed to update EXIF in $FILE";
Or on the command line:
exiftool -XResolution=300 -YResolution=300 -ResolutionUnit=inches file
+.jpg
For the computer, this DPI information is relatively useless, because the computer only cares about how many pixels the image has. You can change this header all you want and the pixel data will not change, the image will not be resized to a different number of pixels. The DPI information will only become useful to a printer. But most printers that I know will always let you specify the DPI you want to print with as a separate setting. The only scenario I can imagine where the above will be useful to you is if you have some program or printer that does care about the DPI information stored in the image header.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.