Re: Setting DPI of image data
Re: Setting DPI of image data
- Subject: Re: Setting DPI of image data
- From: Marcel Weiher <email@hidden>
- Date: Fri, 11 Jul 2008 01:20:59 -0700
On Jul 10, 2008, at 20:16 , Graham Cox wrote:
I'm using NSBitMapImageRep's -representationUsingType:properties:
method to convert data to JPEG, TIFF, etc. I'd like to be able to
specify the DPI of the image. I can calculate the right number of
pixels needed for a given DPI OK, but the image always comes up as
having 72 dpi when opened in another app. Is there a way to set this
property at this level, or am I forced to drop down into Image I/O?
DPI of the NSBitmapImageRep is controlled indirectly via the 'size'
instance variable, with the size given in Postscript points. I just
tried it out and it still works as expected, at least when generating
a TIFFRepresentation:
marcel@tuvok[Pictures]stsh
> image := NSBitmapImageRep alloc initWithData:(NSData
dataWithContentsOfFile:'IMG_0193.JPG')
> image
NSBitmapImageRep 0x232800 Size={1126.4, 844.8}
ColorSpace=NSCalibratedRGBColorSpace BPS=8 BPP=24 Pixels=2816x2112
Alpha=NO Planar=NO Format=0
> image size.
{1126.4, 844.8}
> image TIFFRepresentation writeToFile:'/tmp/img0193.tiff' atomically:
1.
1
> image setSize:((image size) / (2@2))
> image size.
{563.2, 422.4}
> image TIFFRepresentation writeToFile:'/tmp/img0193_d2.tiff'
atomically:1.
1
> ^D
Bye!
marcel@tuvok[Pictures]pd /tmp
/tmp ~/Pictures
marcel@tuvok[tmp]tiffutil -info *.tiff
*** img0193.tiff
Directory at 0x1104008
Image Width: 2816 Image Length: 2112
Resolution: 180, 180
Resolution Unit: pixels/inch
Bits/Sample: 8
Sample Format: unsigned integer
Compression Scheme: none
Photometric Interpretation: RGB color
Orientation: row 0 top, col 0 lhs
Samples/Pixel: 3
Rows/Strip: 15
Number of Strips: 141
Planar Configuration: Not planar
*** img0193_d2.tiff
Directory at 0x1104008
Image Width: 2816 Image Length: 2112
Resolution: 360, 360
Resolution Unit: pixels/inch
Bits/Sample: 8
Sample Format: unsigned integer
Compression Scheme: none
Photometric Interpretation: RGB color
Orientation: row 0 top, col 0 lhs
Samples/Pixel: 3
Rows/Strip: 15
Number of Strips: 141
Planar Configuration: Not planar
marcel@tuvok[tmp]
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden