How to set DMG window and background size using javapackager ant task - dmg

After long struggle I managed to generate (using Ant) on MacOSX (Yosemite) a DMG (of modular JavaFX application that deploys to *.app folder) even with custom icons of the app and DMG volume (both stored as *.icns files in build's package/macosx folder). Drag and drop works, it installs the app, the app launches so everything is fine. Well, almost.
I was tempted to make also the custom background for DMG. It is placed together with the icons in package/macosx folder as App-background.png file (where App part is the name of my app, as it is with icons). And javapackager actually picks up the background, but unfortunately after opening DMG the background seems to be placed in windows' top-left corner, the window itself is like twice the size of the background, so 3/4 of the window's background is just white.
I tried with different PNG sizes, but to no avail. DMG window is always way bigger than the image.
Is there any way to make javapackager (aka fx:deploy which I actually use) to generate DMG with proper settings, that just make the DMG window fit background size?
Edit: It seems like DMG window has actually the size of the PNG (the original background file), but for some reason the image, when displayed as background, is "slightly" scaled down.

After long investigation I found the (not so obvious and rather not direct) reason for this misbehavior. Fortunately I found also the solution.
Apparently there's some problem with Finder handling PNG while displaying DMG file. It all comes down to chunk pHYs which contains 3 fields (4b, 4b and 1b long respectively). It is pixels per unit on x axis, pixels per unit on y axis and 0 or 1 for unit (0 no unit, 1 a meter unit). Playing with these values (via hex editor) did change somehow scaling behavior (and window size), but I wasn't able to figure out correct values. Eventually I get rid of this chunk completely (exporting from GIMP as PNG without saving resolution) and that solved the case.
So for anyone struggling with this: just make sure, there is no pHYs chunk in PNG file.
Edit: One can do that easily with ImageMagick:
$ convert image.png -define png:exclude-chunk=pHYs image.png
This strips pHYs chunk from the image.png file.

Related

APNG files not working in Xcode for iMessage Stickers?

I'm having trouble getting .APNG files to work - they preview correctly in Firefox (meaning when drag'n'dropped into a Firefox window, they animate the way they're supposed to) but when I drag'n'drop the same file into xcode, I see only the first frame. No animation. When previewing in a simulator, no animation - just a static sticker.
The same files animate correctly in an iMessage timeline when sent as attachments (like animated GIFs)..so the files are good.
Also, it's not a size issue - one of them is 16 Kb, and about 400x260. Some are larger in file size but smaller in frame size, none are over 350 Kb.
It's just Xcode that doesn't like them.
I know how to make animated sticker packs - I have two for sale already. For those, I used PNG sequences. I'm trying to use .APNG files because I'm getting way better compression.
I've used PNG Animator as well as apngasm to create the .APNGs, and they are all at or under 300 Kb in size, and under 600 pixels in size.
Is anyone successfully using .APNG files for creating animated stickers?
KM
https://itunes.apple.com/us/app/markup-stickers/id1157027020?mt=8
UPDATE! GOT IT TO WORK!
I needed to import them as stickers, or static image files, and NOT as a sticker sequence, and also needed to name them .PNG and not .APNG.
Success!
KM

How to remove anti-aliasing in PDF images?

I use Abbyy FineReader for ScanSnap to OCR a couple of scanned PDF files. The software claims it retains the original PDF images. The PDF file sizes pre-OCR and post-OCR are almost identical, which is good.
After the software is done, all PDF images appear anti-aliased in Acrobat X. Page navigation is much slower than before, and when I zoom in/out, the images first go to what looks like the pre-anti-aliasing version before quickly changing to anti-aliased images.
Left: Scanned PDF / Right: after OCR with Abbyy
I would like to get the original images without anti-aliasing back. Interestingly, when I open a single page from the anti-aliased PDF in Photoshop, there is no anti-aliasing and the image looks like the left one.
My limited PDF programming experience leads me to believe that Abbyy likely sets some kind of anti-alias flag for each image during OCR processing. How do I un-set this flag?
Any pointers to useful ideas would be much appreciated.
After the software is done, all PDF images appear anti-aliased in Acrobat X. Page navigation is much slower than before, and when I zoom in/out, the images first go to what looks like the pre-anti-aliasing version before quickly changing to anti-aliased images.
Actually in the original file 2013_11_15_22_51_31.pdf contains a JPEG image while the OCR'ed file 2013_11_15_22_51_31_OCR.pdf contains a JPEG2000 image.
Comparing them in third party viewers, it becomes clear that the image in the OCR'ed file is not inherently anti-alias'ed. Furthermore there is no evident flag in the PDF instructing PDF viewers to apply anti-aliasing to the JPEG2000 image. Thus, Adobe Reader seems to automatically render JPEG and JPEG2000 images differently, applying anti-aliasing to the latter but not to the former.
Comparing both images in detail, though, it becomes clear that these images are not identical but instead the image in the OCR'ed PDF is slightly rotated.
I assume Abbyy FineReader recognized that the original scanned image is not correctly oriented. Thus, it rotated it slightly to correct this orientation.
Thus, replacing the image in the OCR'ed version with the one from the original one is no option: Due to the rotation the OCR information would partially be somewhat off.
What you might want to try is to recode the JPEG2000 image to JPEG and replace the image in the OCR'ed version with this recoded one. This will mean some loss of quality but most likely you can get rid of the anti-aliasing this way.
Be aware, though, that the JPEG2000 image is slightly larger than the JPEG image to accomodate for the rotation.
PS: As #VadimR pointed out, there is indeed an /Interpolate true entry in the image dictionary of the OCR-ed version I missed when looking at the file. This does not seem to be the major issue slowing down the rendering.
There is /Interpolate true entry in image dictionary of OCR-ed version, and that's what causes 'anti-aliasing'. Whether that (and not JPEG2000 instead of JPEG compression) is a cause of slow-down, you check on large enough files.
To un-set this key, the best would be to turn it off while creating a file, and if that's not possible, to write and run a small program in suitable language.
But, since your file doesn't sport 'compressed objects' and offending key is in plain view inside a file, in the spirit of 'job done quickly' you can simply process your file e.g. like this:
perl -M-encoding -0777pe "s!/Interpolate true!' 'x17!ge" <in.pdf >out.pdf

How to convert Autocad drawing to image?

I have an Autocad drawing which is a plan for land squares where each square contains a number.
I tried to convert it to image by choosing: File --> Export Data --> and file format Bitmap (bmp). (I have Autocad 2013 Mac version)
the file converted to image, but the quality is too bad, I can't see the land numbers inside the square when I zoom in the image.
I tried also with Postscript (PS file format), quality is a bit better but it's still bad.
Is there away to convert Autocad file to image but still preserve it's high quality details
I need to convert the file to image because I would like to publish it online on my website. maybe there other was to publish autocad file on line, if so, please advice. But the trick I want the background of the autcad (plan) to be transparent so that I could display it on top of Google maps. I if I used autocad plugin I can't make it transparent. right?
Use the PLOT (for the current drawing) or PUBLISH (for batching) commands to produce high quality images.

How do you make a Cocoa toolbar image

I'm an experienced developer but a relative newbie with Cocoa. The Cocoa documentation says that toolbar items (NSToolbarItem) are 32x32 in regular size and 24x24 in small size. It goes on to say that you can (and should) include an image that includes both sizes and that a multi-page TIFF or an ICNS file can be used. This is where I am confused. I have tried several different programs that create ICNS files but all of them create files including 16x16, 32x32, and bigger. Is the assumption that the 24x24 toolbar icon uses a 16x16 image or is there a way to create a ICNS file with a 24x24 image? Or are people using an application to create multi-page TIFF files?
Use Icon Composer.app and supply the 16 and 32 sizes. The system will automatically up- or down-scale between them as needed and usually does a very good job of it.

Resize JPEG and save new file to JPEG on Mac OS X using Cocoa

I am a bit confused about what the best approach is to resize a JPEG file on disk and save the resized JPEG as a new file to disk (on Mac OS X with Cocoa). There are a number of threads about resizing, but I am wondering what approach to use. Do I need to use Core Graphics for this or is this framework "too much" for a simple operation as a resize? Any pointers are welcome as I am a bit lost.
Core Graphics isn't “too much”; it's the right way to do it.
There is a Cocoa solution:
Create an image of the desired size (the destination image).
Lock focus on it.
Draw the source image into it.
Unlock focus on it.
Export it to desired file format.
Write that data somewhere.
But that destroys metadata.
The Core Graphics solution is not a whole lot different:
Use an image source to load the image and its metadata.
Create a bitmap context of the desired size with the source image's color space. (The hard part here is making sure that the destination context matches the source image as closely as possible while still being in one of the supported pixel formats.)
Draw the source image into it.
Capture the contents of the context.
Use an image destination to write the image and metadata to a file.
And the Core Graphics solution ensures that as little information as possible is lost along the way. (You may want to adjust the DPI metadata, if present.)
Install and use ImageMagick.

Resources