topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday March 29, 2024, 12:51 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Use batch script to merge 2 .png files into single png or other option  (Read 5306 times)

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
This is a little bit off my usual day-to-day dealing with documents. 
I need a way to take two .png files (each contains text but not text that would recognized by OCR software) and combine these end to end to make a single line. 
As an example. 
If "This.png" was a picture of the words "City of Angels".  And "That.png" which was a picture of the words "Sanitation Department".  I need 'add' them end to end to make "This+That.png" which would read "City of Angels Sanitation Department".  And then i need to shrink the results to a size no longer than would fit on an 8.5 wide sheet of paper.

I could, I would just extract the text from each .png to start with but nothing i have tried works consistently to read them. In the end, I may end up searching for each occurrence and just typing the lines of text by hand.  But finding a way to add two image files might come in handy for other things one day :)  and if scripted it could be plugged into a a larger script that i run on the same files daily

As a side question, I also considered using "echo" to get each png file into a pdf if that is possible.    I would also be more than willing to drop the effort if someone can tell me it is going to me nearly impossible to accomplish :mad:.




4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,641
    • View Profile
    • Donate to Member
Using ImageMagick Q16 x86 portable:

1) Extract to a folder
2) Open a CLI there
3) To append:
Code: Text [Select]
  1. convert.exe "this.png" "that.png" +append "this+that.png"
4) To resize to 8.3", assuming 200DPI otherwise recalculate the pixel values:
Code: Text [Select]
  1. convert.exe "this+that.png" -resize 1660x2340 "this+that+A4.png"


You can also use ImageMagick to convert PNG to PDF:
Code: Text [Select]
  1. convert.exe this.png this.pdf

You'll probably need to play around with the options to get the output how you want.

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
Neato!  I found that very program just this afternoon.  Downloaded and installed it but have not even looked to see if it would do the job.  I had just about reached that point of "not worth the effort" and because this is all part of an ongoing job, i moved the problem to the front instead of the end and wrote in the commands to create the text files from the original input instead of the other way around.  The "orders" all come in text but they want the output in png's for use on websites having the correct "artsy look".
Now they come along and want those same "words" converted back to be used in a list format.

Those that are already "done" are done.  I will just have to "undo" them (maybe 30 or so) but going forward, i started creating plaintext documents from the "orders" at the start before I use Photoshop or other art program to create the pngs.  Then i dont have to "un-artify" the text afterward.

I just thought it was an interesting idea and wondered if it could be done.  cat.png+mouse.png=dinner.png  :)
Any ideas on the other one?  I just PM'ed you an idea i had about making the list to use for input checks taking the output from dir /b.

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,612
    • View Profile
    • Donate to Member
Why aren't you creating complete .png files from your text sources?

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
I probably wasn't clear enough.  I actually do make the png files (or have been) from the original text.  But the text comes in written in various formats ad i am creating titles for their webpage from it.
Once i get the text arranged properly that is exactly what i have been doing , Creating the pngs and this has been fine for several years.  A new "addition" to the office has decided he can't be bothered with clicking links to see what page they go to and it wold be too long to put the entire description in the hyperlink to a website.  He cannot figure it out from the first letter of each work.  As above www. "coasd.com" for "city of angels sanitation department".  He now wants me to create a text file from the already converted pngs that he can import into Excel.  So he can read what goes to which.

I was looking for a way to go back and do it after the fact by scripting rather than by hand.  Going  forward.. Yes, I wrote that into the "site-creation" scripts to save this info as text tags as well as the final png files. 

4wd's solution was perfect and it was lucky for me I had found that exact same utility and installed it on my server but had not yer tested because it looked pretty complicated.  I would like to report that it is a "fantastic" utility that I wish I had known about long ago.  I am sure that I will have plenty more uses for it.  I did not bother try the portable and went straight to the installed Q16 X64. a decision i hope won't come back to 'bite me' :(

But the convert.exe is now in my path and the command runs from anywhere.  As soon as i can work out all the settings to get exactly what i need it will be a perfect fit!   Thanks 4WD

PS:  I know i asked for an "end to end" combination (And it works great!) but do you know the correct command to STACK the images as well?

AGAIN! 

I hope you can also find me a VIM script or whatever it take to add the two <enter> at the end of each use of Paste so I end up with a double spaced list using only copy/paste to get there.
« Last Edit: February 12, 2016, 02:57 PM by questorfla »