PDA

View Full Version : Basic token, portrait and images from PDF question



Varsuuk
April 29th, 2022, 16:55
I have usually only worked on code or xml with the most vestigial of art ;)

If I want to do something more properly, what are the tools to extract images from PDFs in the best way in order to allow later resizing. I presume extracting in the "native" image properties/resolution to some tiff/png etc? format.

What tools can be used to do this best or easiest or both? Please suggest free/open-source as well as paid if you know of both.

[
EDIT: all the meanderings of my poor memory and attempts to recreate something I might have done "wrong" to begin with ;) - the above is what is import:
1. If I want make a page(s) an image for later resizing - what do I use app wise and if it isn't obvious only - menu path. (Tips on resizing are welcome if there are best practices other than resize 1x only if can)
2. If I want to take a PDF page that is made of multple layers and want to extract each (or some if can choose) layers like in #1 - what app and option
3. If the image is already merged, then I would, what, save in some X fromat from the PDF then use a crop tool in the art app to grab the portion I wanted.
]



-------------------- meanderings on figuring out what I did 2 years ago are below... -----------------------

I started last night extracting images from a PDF for makign a thumbnail and using GIMP, I scaled it to 100x100 and then exported as png.
But when I was trying to recreate extracting of "subimage" stuff - I cannot recall what tools I used.

Just recently, I opened some PDFs in Acrobat and rightclicked a portait to save as and found it stored it as an 833x980 tiff. But this was part of a PDF I did the first pass (wanted to resize my tokens since I did them all at 256 - including adding one of those circles with tokentool (I HATE subjective stuff, never satisfied with placement centering or size lol... sigh). But I found my old "staging directory" filled with images I extracted with names that I am not sure if there the "automatic" name (I seem to recall I opened with and saved to "images" or I used a converter app to save to images - it's all hazy from May of 2020 :(

The above image I saved today, was the same as the "..._0002..." images below so - "save image" from within Acrobat saved it as 833x980

The file names I found were like:
WOTD -TheSurvivors_Page_01_Image_0001.png (pretty sure the method I used befofe extracted to TIFF files and then I saved as png but erased the tiffs at some point...)
WOTD -TheSurvivors_Page_02_Image_0002.png
WOTD -TheSurvivors_Page_02_Image_0003.png
...


But I am not sure. The above may have been me saving parts of the images extracted originally as TIFF. I DID find a directory where there were TIFF images, multiple per "page" of a PDF. In particular, it appeas like it saved each of the 3? layers - Portrait (in a character sheet), Bacxkground (of character sheet) and text (on character sheet) maybe other images extracted too - but I deleted all but the sheet and image/portrait I think. Eventually I must have deleted the TIFFs.

These had names like:
WOTD - Character Sheet - TheSurvivors (filled sheets)_Page_02_Image_0001 (9600x12596 for an unfilled char sheet layer part of next image)
WOTD - Character Sheet - TheSurvivors (filled sheets)_Page_02_Image_0002 (3341x3933 for an image of the character that was in a layer fititng in the "portrait" box of the character sheet.)

So it drives me nuts in 2 ways - 1) I have a crap memory and cannot recall what I did to "bulk extract" the images 2) I don't know what resolution is "right" as the start point before scaling/resizing. I SUSPECT the one with the weird names above because in the import, I recall something about a checkbox to "import native reso" or something similar.


So please, tips from those who convert from the PDF vs getting the original art.

Regards,
Vars

Zacchaeus
April 29th, 2022, 17:19
You can use this to extract images from a pdf https://www.fantasygrounds.com/forums/showthread.php?40832-How-To-Extract-Images-From-A-PDF

Varsuuk
April 30th, 2022, 01:01
NICE! Thanks Zacchaeus, I DID use this in the past, probablyt years ago after reading that link (probably alerted to it by you...)

OK cool, this is interesting - the exported "portrait" layer image is nearly exactly the size of the "save image" right click from Adobe Acrobat. Which is cool in several ways - 1) It verifies that that IS the "original" resolution, so those crazy big resos I had was whatever other tool I used to grab it and probably SET the resolution higher for the extract - which, I am sure is adding "noise" since if it was 600x800, extracting at like 2400dpi resulting in whatever higher LxH value is not a "true" image, it is upscaled. Which means when I took that and downscaled ;) I was adding even more noise for two different reasons 2) I now know what I used for ONE of the old dirs of these images, one dir has a set of images that matched what this app put out. 3) I can finally put to rest wondering what is the "right" starting reso and can get back to redoing (ugh) my tokens from the 256x256 (for man sized) to 100x100 which was recommended.

thanks!

Varsuuk
April 30th, 2022, 05:13
Well.. it was exciting to see and I tried it.

And found the 100x100 token that TokenTool created for me (from the JPG) was no where near as sharp as the one I made 2 years ago from some graphics app that asked the "resolution" (forgot term) when opening a PDF. I recall trying various sizes (NAIVELY) trying to find the highest size supported (ie, that didn't run out of memory converting) and saved it in TIFF (thinking lossless - see, key here is I know so little I am dangerous) from TIFF my workflow was to open it in something like Paint3D since that let me easily make a portrait by first cropping to 1:1 ratio that excluded the edges I didn't want in the picture. Then I opened TokenTool, picked a simple border and selected size 256x256 (originally did in 100x100 and didn't like the fuzzy/jagged corners in the TokenTool closeup) I dragged the saved full-sized PNG to it and saved the token. Then I scaled to 100x100 and exported to JPG in Paint3D for the "Portrait" image.

When I looked the output of the pdfextract was a jpg of the same size as the png I extracted (manually one at time) from Acrobat. So I tried it with the PNG from Acrobat. When I copied it to TokenTool it came out really fuzzy, especially compared to the 256 token (and worse if zoom in to make them about the same screen size)

See pic: 52599
1) TokenTool image is from my Acro-PDF same "native" reso of 833x980 as your pdfextract make (but that was jpg and figured resizing it would cost more than resizing png)
2) The token png on bottom right is the token I made 2 years back (as described above) in 256x256
3) Bottom left is the newly extracted jpg via pdfextract.

** NOTICE, #3 has artifacts/noise all along the right and bottom borders. This appears in same spot on all 22 extracted images. I tried a new extract and same problem. Seems to only happen with the tool, not any other way I used to manually extract. So I think I cannot use that - will see in another PDF when get to one.

Then it hit me... well ummm the old one is 256x256 - maybe THAT not the original (fake) starting size is the issue. So I tried making from the just extracted (Acrobat) png with same 833x980 starting points (not like the 5K x 5K or so pixels of the 2 year old one) and yup, setting token tool to 256 resulted in a much nicer image. But I am guessing since everyone uses 100x100 that it will not look bad in use. It just looks lacking because it is much bigger on my screen than it would be in the game and it had nothing to do with starting with some sick reso - at long as I startred with "native" reso, I would not get anythingh better if compared apples to apples.

The new 256x256 compared to the 100x100 zoomed to same size compared to the same 100x100 left at native display size: 52600



So in summary, 256x256 clearly looks better but since what is "degrading" on my token must also be happening for everyone else who is downscaling to 100x100 from a larger image - I will live with it :)
If there is anything someone can suggest to make my work more efficient - flow sumarized below, please let me know - I've mixed multiple apps to do this:

1. Open PDF in Acrobat Reader DC (I have an older Adobe Pro as an option).
2. Click on image I want, right click and save as TIFF(I have options for TIFF, JPG, BMP)
3. Open image in Paint3D - select crop 1:1 tool.
4. Resize crob border on left/right sides until "ragged" edges are not seen (the source has a ripped paper border all around) then shift up/down to center best.
5. Save new square image (still TIFF)
6. Drag square TIFF to TokenTool (set to 100x100)
7. MouseWheel resize (WISH I could type a size of the image vs wheel scroll I fear it is adding like 1% noise each resize...) until it fits in the circle well and center as wish.
8. Save token as PNG
9. Take Square TIFF and export to 100x100 JPEG 70% using GIMP (didn't see a way to set JPG Compression in Paint3D (see how I am in need of more integrated toolset ;) I'm sure something can do the square crop and export easily enough. I'd use GIMP except the Transform/Crop menu doesn't seem to let me pick "shapes/ratios" like the Paint3D does with nice click for SQUARE CROP.

That's it. Seems too complicated. I can do it, but would like more in one or two app workflows.