So i have many well logs in pdf format i convert them to Tiffs which my software can use but they are separate images for the different pages
each PDF is about 50 pages so i got 50 images to stick in order however that may vary i a thinking define a variable to be set by the user
i have some ideas but would like some advice on where to start don't write me any code i can do that but any ideas would be much appreciated
remember there are hundreds of PDFs so dont call me lazy i would die if i did that all manual
Stitching thousands of images together with AHK Topic is solved
-
- Posts: 31
- Joined: 11 Nov 2015, 22:29
Re: Stitching thousands of images together with AHK
Hello Tactical.
I can think of two ways to do it:
1 - GDIP (Create a canvas with enougth size (sum of all heights and maximum width) and than proceed to paste the images one after the other in the canvas based on height (next images will be pasted on current coordinate + last images height).
OR
2 - Study the file structure for .tiff and than write a new .tiff file holding all the images.
Number 2 will probably have far better results (i even doubt the software in question would know how to individualize the images if do it the first way) but it will also require the most effort. Either way, it will be an excellent exercise and well worth the effort you put into it.
Feel free to ask any questions regarding the file structure (and how to assemble it using AutoHotkey).
Best wishes.
I can think of two ways to do it:
1 - GDIP (Create a canvas with enougth size (sum of all heights and maximum width) and than proceed to paste the images one after the other in the canvas based on height (next images will be pasted on current coordinate + last images height).
OR
2 - Study the file structure for .tiff and than write a new .tiff file holding all the images.
Number 2 will probably have far better results (i even doubt the software in question would know how to individualize the images if do it the first way) but it will also require the most effort. Either way, it will be an excellent exercise and well worth the effort you put into it.
Feel free to ask any questions regarding the file structure (and how to assemble it using AutoHotkey).
Best wishes.
"What is suitable automation? Whatever saves your day for the greater matters."
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!
Archmage Gray - A fantasy shooter game fully coded in AutoHotkey
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!
Archmage Gray - A fantasy shooter game fully coded in AutoHotkey
-
- Posts: 31
- Joined: 11 Nov 2015, 22:29
Re: Stitching thousands of images together with AHK
thank you i might have to do number 2 however all i need to do is the equivalent of someone using an image editor dragging a bunch of pictures together but it might be more effective and clean to do the thing you said about the file structure but how would what you described even be acheived witha n image editing program or would it be all non visual and would i be able to do something like that with c++ because that seems like a better way of doing itGio wrote:Hello Tactical.
I can think of two ways to do it:
1 - GDIP (Create a canvas with enougth size (sum of all heights and maximum width) and than proceed to paste the images one after the other in the canvas based on height (next images will be pasted on current coordinate + last images height).
OR
2 - Study the file structure for .tiff and than write a new .tiff file holding all the images.
Number 2 will probably have far better results (i even doubt the software in question would know how to individualize the images if do it the first way) but it will also require the most effort. Either way, it will be an excellent exercise and well worth the effort you put into it.
Feel free to ask any questions regarding the file structure (and how to assemble it using AutoHotkey).
Best wishes.
- JoeWinograd
- Posts: 2214
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: Stitching thousands of images together with AHK
This can be done easily with the montage feature in either GraphicsMagick or ImageMagick. Here's an article I wrote that discusses how to do it with GraphicsMagick:
Create an image (BMP, GIF, JPG, PNG, TIF, etc.) from a multi-page PDF
And when I say easy, I mean easy — literally one command line — although there are a ton of options. Regards, Joe
Create an image (BMP, GIF, JPG, PNG, TIF, etc.) from a multi-page PDF
And when I say easy, I mean easy — literally one command line — although there are a ton of options. Regards, Joe
-
- Posts: 31
- Joined: 11 Nov 2015, 22:29
Re: Stitching thousands of images together with AHK
Code: Select all
C:\Users\**>gm.exe montage -tile 2x10000 C:\Users\**\Desktop\PDFs\Clasifiedname.PDF output.tif
gm.exe montage: Failed to find Ghostscript (not installed?). ("" -q -dBATCH -dMa
xBitmap=50000000 -dNOPAUSE -sDEVICE=ppmraw -dTextAlphaBits=4 -dGraphicsAlphaBits
=4 -r72x72 "-sOutputFile=C:\Users\**\AppData\Local\Temp\gm8AIEYg" -- "C:\User
s\**\AppData\Local\Temp\gmGao6Tl" -c quit).
edit: i also couldn't find the output file iit said was made in my appdata folder
- JoeWinograd
- Posts: 2214
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: Stitching thousands of images together with AHK
> thats the error i got not sure what its on about what is ghost script?
Ghostscript is an extremely popular, open source interpreter for PostScript and PDF. Many imaging products call it to perform rasterization/rendering of PDF files. Its website is here:
http://www.ghostscript.com/
The downloads are here:
http://www.ghostscript.com/download/gsdnld.html
Install the Ghostscript with the same bit-level as the GraphicsMagick you installed (32-bit or 64-bit).
> i also couldn't find the output file iit said was made in my appdata folder
Since it didn't find Ghostscript, it probably didn't make an output file. Should work fine once you have Ghostscript installed, but you can test it before that by making the source file a BMP, JPG, PNG, etc., i.e., it needs Ghostscript because your source file is a PDF.
Regards, Joe
Ghostscript is an extremely popular, open source interpreter for PostScript and PDF. Many imaging products call it to perform rasterization/rendering of PDF files. Its website is here:
http://www.ghostscript.com/
The downloads are here:
http://www.ghostscript.com/download/gsdnld.html
Install the Ghostscript with the same bit-level as the GraphicsMagick you installed (32-bit or 64-bit).
> i also couldn't find the output file iit said was made in my appdata folder
Since it didn't find Ghostscript, it probably didn't make an output file. Should work fine once you have Ghostscript installed, but you can test it before that by making the source file a BMP, JPG, PNG, etc., i.e., it needs Ghostscript because your source file is a PDF.
Regards, Joe
-
- Posts: 31
- Joined: 11 Nov 2015, 22:29
Re: Stitching thousands of images together with AHK
okay it works but the resolution trash is there a way to make the resolution render out better
- JoeWinograd
- Posts: 2214
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: Stitching thousands of images together with AHK
> okay it works
That's great! You're welcome.
> is there a way to make the resolution render out better
If you didn't specify the -density option, which is the horizontal and vertical resolution in pixels of the image, then it defaults to just 72 DPI. I suggest trying 200. You may read about this option here:
http://www.graphicsmagick.org/GraphicsM ... ls-density
If you didn't specify the -quality option, which is the compression level for JPEG, PNG, and TIFF, then it defaults to just 75. The range is 0 (lowest image quality and highest compression) to 100 (best image quality and lowest compression). I suggest trying values from 90 to 100. You may read about this option here:
http://www.graphicsmagick.org/GraphicsM ... ls-quality
When used in conjunction with montage, the -geometry option specifies information about the tiles. I suggest making it 100%. You may read about this option here:
http://www.graphicsmagick.org/GraphicsM ... s-geometry
Taking into account everything above, the command that you showed in your earlier post would look like this
Warning: this will result in a large (uncompressed) TIFF file.
You may (or may not) get better quality results by using Xpdf's pdftopng.exe utility to convert the PDF to PNGs first, then create a TIFF montage with GraphicsMagick from the PNGs created by pdftopng. Download for the Xpdf utilities is here:
http://www.foolabs.com/xpdf/download.html
Regards, Joe
That's great! You're welcome.
> is there a way to make the resolution render out better
If you didn't specify the -density option, which is the horizontal and vertical resolution in pixels of the image, then it defaults to just 72 DPI. I suggest trying 200. You may read about this option here:
http://www.graphicsmagick.org/GraphicsM ... ls-density
If you didn't specify the -quality option, which is the compression level for JPEG, PNG, and TIFF, then it defaults to just 75. The range is 0 (lowest image quality and highest compression) to 100 (best image quality and lowest compression). I suggest trying values from 90 to 100. You may read about this option here:
http://www.graphicsmagick.org/GraphicsM ... ls-quality
When used in conjunction with montage, the -geometry option specifies information about the tiles. I suggest making it 100%. You may read about this option here:
http://www.graphicsmagick.org/GraphicsM ... s-geometry
Taking into account everything above, the command that you showed in your earlier post would look like this
Code: Select all
gm.exe montage -tile 2x10000 -geometry 100% -density 200x200 input.pdf -quality 100 output.tif
You may (or may not) get better quality results by using Xpdf's pdftopng.exe utility to convert the PDF to PNGs first, then create a TIFF montage with GraphicsMagick from the PNGs created by pdftopng. Download for the Xpdf utilities is here:
http://www.foolabs.com/xpdf/download.html
Regards, Joe
Re: Stitching thousands of images together with AHK
- JoeWinograd
- Posts: 2214
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: Stitching thousands of images together with AHK
You're welcome!
Re: Stitching thousands of images together with AHK Topic is solved
This will do it with the Gdip library. I wrote it directly in the browser so it is untested
Appends all tiffs to the right of the last. Easily modified for vertical layout
Update:
Updated code to append images vertically stacked. Left commented code for horizontally
This method uses a lot of memory, but is the quickest. A slower method could be written to use very little memory, by doing the dimension calculations, and then disposing the images in that same loop.
Code: Select all
pToken := Gdip_Startup()
files := []
;widthTotal := 0, heightMax := 0
heightTotal := 0, widthMax := 0
loop, Files, *.tiff
{
pBitmap := Gdip_CreateBitmapFromFile(A_LoopFileName)
Gdip_GetDimensions(pBimap, w, h)
;widthTotal += w
;if (h > heightMax)
; heightMax := h
heightTotal += h
if (w > widthMax)
widthMax := w
files.Insert({ bitmap: pBitmap, w: w, h: h })
}
;pBitmap := Gdip_CreateBitmap(widthTotal, heightMax)
pBitmap := Gdip_CreateBitmap(widthMax, heightTotal)
;xCurrent := 0
yCurrent := 0
loop % files.MaxIndex()
{
f := files[A_Index]
;Gdip_DrawImage(pBitmap, f.bitmap, xCurrent, 0, f.w, f.h, 0, 0, f.w, f.h)
;xCurrent += f.w
Gdip_DrawImage(pBitmap, f.bitmap, 0, yCurrent, f.w, f.h, 0, 0, f.w, f.h)
yCurrent += f.h
Gdip_DisposeImage(f.bitmap)
}
Gdip_SaveBitmapToFile(pBitmap, "myFile.png")
Gdip_Shutdown(pToken)
Update:
Updated code to append images vertically stacked. Left commented code for horizontally
This method uses a lot of memory, but is the quickest. A slower method could be written to use very little memory, by doing the dimension calculations, and then disposing the images in that same loop.
-
- Posts: 31
- Joined: 11 Nov 2015, 22:29
Re: Stitching thousands of images together with AHK
thanks for writing this but i discarded the autohotkey approach for using c++ and graphics magic but thank you for this and im sure this will help anyone else not using c++
Who is online
Users browsing this forum: Google [Bot] and 285 guests