1

Problem:

I have a default OSX cursor file, that I want to modify and save as PNG to later load in my program.

Current solution:

I found an online PDF -> PNG converter, which did the job, however turns out this converter didn't keep the transparency in the resulting PDF and used white color where the alpha channel should be.

So, now I need to have the file converted and keep the alpha channel.

Is there something online or some kind of software that can do that?

10
  • What platform? Can you post the pdf somewhere so we can test it?
    – Tetsujin
    May 31, 2022 at 6:06
  • @Tetsujin, I don't care about platform.
    – Igor
    May 31, 2022 at 11:16
  • Are you looking for a free solution or a commercial product? May 31, 2022 at 13:51
  • how is a converter to know to keep the 'alpha' as pdf don't contain alpha (to my knowledge)
    – depperm
    May 31, 2022 at 14:06
  • @depperm - that's why I want to see the file. See what it comprises; a PDF is really just a container.
    – Tetsujin
    May 31, 2022 at 14:54

1 Answer 1

1

ImageMagick can probably do everything you need.

I'll start by copying one of the cursor PDFs to my Desktop:

cp \
 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/Resources/cursors/busybutclickable/cursor.pdf \
 ~/Desktop/cursor.pdf

ImageMagick's convert tool alone can convert a PDF to PNG, and will also remove the white background:

convert cursor.pdf cursor.png

and I get:

cursor.pdf straight conversion to P-N-G file

If you need a higher-resolution conversion, drop-in the -density ### option:

convert -density 300 cursor.pdf cursor.png

Once you have a basic conversion that you're happy with, you can then make the convert command slice up the image for you.

Using the default conversion, I get a 28x600 px image, and there are 15 individual images, which is 28x40 px per image, so I tell the convert command that I want it to slice the image into a series of images that are 28x40 px:

convert cursor.pdf -crop 28x40 +repage +adjoin cursor-%02d.png

and now I have 15 individual PNGs, with transparent backgrounds:

ls cursor-*.png
cursor-00.png   cursor-03.png   cursor-06.png   cursor-09.png   cursor-12.png
cursor-01.png   cursor-04.png   cursor-07.png   cursor-10.png   cursor-13.png
cursor-02.png   cursor-05.png   cursor-08.png   cursor-11.png   cursor-14.png

(%02d is syntax from the printf command which means "print a digit, padded 2 places with a ``0'' (zero)". This is just nice for sorting/displaying numbers, like in the ls command above.)

For macOS, ImageMagick recommends installing through brew:

and I found those spells above (ImageMagick slang for commands and options/paramaters) from these StackOverflow posts:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.