topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Tuesday March 19, 2024, 12:03 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: Using script to copy multiple image files to a page  (Read 7718 times)

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
Using script to copy multiple image files to a page
« on: May 24, 2016, 09:13 PM »
I am trying to find the best way to perform a 'copy/paste' action on certain images in a group of folders so they end up displayed stacked over the next in a Word document or pdf file.  The script is used to gather various pieces of information from a group of folders and one item that needs to be added is an image file in each folder set named invite.png (or jpg).   This image is about 5"W x 2.5"H  (750x350p approx) and I can get close to 4 on a page doing copy/paste manually. 

But every variation I have tried in the looping script ends up with a list of 'file path names" in a list instead of a stack of images where the image file is copied as a picture not a file-path. 
I have tried various functions from Image Magick and Graphics Magick but nothing has worked so far.  Any advice appreciated.


4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,640
    • View Profile
    • Donate to Member
Re: Using script to copy multiple image files to a page
« Reply #1 on: May 25, 2016, 05:31 AM »
um, what?

This image is about 5"W x 2.5"H  (750x350p approx) and I can get close to 4 on a page doing copy/paste manually.

It would be helpful if you provided a sample output file/image.  Otherwise, something like the way this appends?

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
Re: Using script to copy multiple image files to a page
« Reply #2 on: May 25, 2016, 01:03 PM »
Perfect 4wd. Thanks I had looked high and low for something like tha
I have started using Image Magick quite a bit and only recently learned of it's 'sister fork' Graphics Magick
I am always amazed at what can be done with image files through command line which is essential in order to automate things.
I was looking into converting all the png to pdf and then compiling the pages but that is a waste as only one image per  page.

Don't suppose it can be tweaked to add the URL link embedded as can be done in WORD, Outlook etc?
Had to ask :).
You are alread familiar with the setup, it is that same bunch of mini websites and I was sked to add the invitation image to the list, Before someone asks me also add the URL I figured I would so it so whe they ask I can just :)
Smile..  Hehe

PS:  I thought 750 pixel by 350 pixel was pretty good description.  If I paste it here I am not sure the size would be representative of the true measure.
I only wanted to impress that that I can put more than one on a page by using copy/paste.  If I knew how to access the contents of clipboard directly, I could have loaded the image in the batch then pasted it from the batch but clipboard access in Windows 10 is not so easy now.  Win-send-keys is deprecated to the point of no .dll file now. But I was looking at "Xclip'"

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
Re: Using script to copy multiple image files to a page
« Reply #3 on: May 25, 2016, 04:43 PM »
Well, it might have worked. :(
Apparently graphics Magic has some issues on Windows 10. 
CopyQ seemed like a good choice too but still no luck in the scipt.
Nircmd may be my only hope!

Target

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,832
    • View Profile
    • Donate to Member
Re: Using script to copy multiple image files to a page
« Reply #4 on: May 25, 2016, 05:13 PM »
trying to understand just what you trying to do here

are you using word, or some other program?  what is the end result (clearly some form of contact sheet, but in what format) and the intended purpose?

so many questions...

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
Re: Using script to copy multiple image files to a page
« Reply #5 on: May 26, 2016, 02:25 AM »
I will try. 
Each Project has an image created for it called invite.png. Each one is a specific picture that is like a miniature of the login page that section of the main site.  During creation of each new Project, there is a script that takes several components to create this and performs many other housekeeping functions. 
The Names for each project are kept as short as possible by using initials that com from the project name so it could be www.projects.com\joedoe\cdcsoi.  This is short and simple but if you were to see that name later and it was one of a 100 others you have no way to know for sure what it is.
The "invitation" is a 30% reduction image of the complete login page which makes it easy on humans to see what the initials stand for.
in this case: joe doe is looking for a chief dog catcher (for the) state of Illinois.
During the creation of the project, when i have the invite.png file at hand if i could add the invite.png as a PICTURE to a WORD doc listing all the Projects along with their URL's it would be a handy thing to have

I already make a list of the URL's but "1 picture speaks 1000 bytes"  I could embed the URL into the png and the person using the list could just click the invite.png image to get to that Project page

In order to do this and make it fully automatic, i have to be able to copy that image and add it to the Site List plus Use the Hyperlink took to embed the URL within the original creation script

I can go back afterward and do this on a one by one basis very easy.  Copy the invite.png, paste to word doc , it pastes just fine as an image cRight click the image click the hyperlink option and type in the correct URL.
Job done to perfection.

But it is a lot more complicated thanvthat and i have all the parts needed at hand when the site is created to be able to automate the creation of the picture list with embedded URL's if i had a command that would runs in the script.

Think of it like a catalog where you click the image to open to the page for the description of the item.  Pretty easy straightforward stuff and i was amazed to find out that while i can find a ton of ways to do it in LINUX Windows apparently does not have a "copy file as Image option.  And definitely not one that had scriptable command line interface for automation.

illinoise dogs catcher.jpgUsing script to copy multiple image files to a page

SO I would have a nice page full of pictures that can easily descrive where they go thta can be clicked to reach each project.

I hope this helps but i don't think all this description will do much to help find a way to do it because there probably thousands of other reasons why someone might want to "copy a file as an image" instead of just copying a file-name or path to a document.   Think Signatures, photo albums, catalogs, etc.  And it is VERY easy to do by hand one at  time. 
But this is MY reason for wanting it and why i want to be able to script it rather than doing a one-up by hand

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,640
    • View Profile
    • Donate to Member
Re: Using script to copy multiple image files to a page
« Reply #6 on: May 26, 2016, 07:20 AM »
Adding images with hyperlinks can be done using Powershell but not having Word I can't try it.

Something along the lines of:
Code: PowerShell [Select]
  1. #Create Word Document
  2. $word = New-Object -ComObject word.application
  3. $word.visible = $false
  4. $doc = $word.documents.add()
  5. $selection = $word.selection
  6. $selectimage =   $selection.InlineShapes.AddPicture(C:\dir1\invite.png)
  7. $doc.Hyperlinks.Add($selectimage.Range,'http://www.project1.com')
  8. $selectimage =   $selection.InlineShapes.AddPicture(C:\dir2\invite.png)
  9. $doc.Hyperlinks.Add($selectimage.Range,'http://www.project2.com')
  10. $selection.TypeParagraph()
  11. $selectimage =   $selection.InlineShapes.AddPicture(C:\dir3\invite.png)
  12. $doc.Hyperlinks.Add($selectimage.Range,'http://www.project3.com')
  13. $selectimage =   $selection.InlineShapes.AddPicture(C:\dir4\invite.png)
  14. $doc.Hyperlinks.Add($selectimage.Range,'http://www.project4.com')
  15.  
  16. $doc.saveas([ref] "C:\document", [ref]$saveFormat::wdFormatDocument)
  17. $word.quit()

With the attendant code to read from a list of invite.png file paths, the associated URLs, and repeating as necessary until the list is exhausted.

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
Re: Using script to copy multiple image files to a page
« Reply #7 on: May 26, 2016, 08:30 AM »
4WD, I have to apologize.

 I can see I am just not making my requests difficult enough :(
:)Next time I will see if I can ask fot the world AND the stars !! :up:Would you believe that I had people on Stack-Overflow asking me what I meant by a "Word Document"!
If you do have anything at all that can hold images and want to test, That is all I really need.  Unless :tellme: it is for a MAC!
I just wanted to give them a picture sheet as most of these people apparently can't read anyway but even if they could some of the titles are less than obvious.
Msufaosdeanofp would be an example of a folder-name.  I can see where a picture might help there.   :thmbsup:
ps: msufaosdeanofp could be shortened to msufaosdop also depends on my mood that day..

Last request (for the day!)  If you have ever seen CopyQ can you tell me why it doesn't work  I don't have anything but Windows 10 and maybe it isn't compatible  I have a lot of thngs that command would work nicely with
« Last Edit: May 26, 2016, 08:40 AM by questorfla »

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,640
    • View Profile
    • Donate to Member
Re: Using script to copy multiple image files to a page
« Reply #8 on: May 26, 2016, 08:31 PM »
Of course there may be simpler ways than playing around with Powershell, ie. write the output as a HTML doc then load into Word and save as a Word file.

eg. Simple HTML output from a command file, etc.
Code: HTML5 [Select]
  1. <title>Index</title>
  2. <tr>
  3. <td><a href="https://www.donationcoder.com"><img src="./test/dir1/invite.jpg" alt="Department of software"></a>
  4. <td><a href="https://www.donationcoder.com"><img src="./test/dir2/invite.jpg" alt="Mouser lives here"></a>
  5. </tr>
  6. <tr>
  7. <td><a href="https://www.donationcoder.com"><img src="./test/dir3/invite.jpg" alt="WTF"></a>
  8. <td><a href="https://www.donationcoder.com"><img src="./test/dir4/invite.jpg" alt="The end"></a>
  9. </tr>
  10. </body>
  11. </html>

You could also add the height and width attributes to the <img> tag to display them the right size to fit the page.

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
Re: Using script to copy multiple image files to a page
« Reply #9 on: May 26, 2016, 09:02 PM »

I just got home and was about to try your first one with WORD.
The 2nd looks very much like the script that i came up with to create the HTML "photo album" which is what it was meant to do.  And I agree that it works fine.  HTML is actually a better format for what i need and going forward, it will work a charm.
But.  I have to make the FIRST one    one by one    for 76 sites.  OR  figure out why it won't script.

Right now working from a folder copy of all the invitation images plus text files loaded with the url for each invitation, i am still having the Dickens of a time getting the value of the invitation.TXT (which is storing the actual URL) to be read into the script variable to for loading the a^href section of the line.

The original code I am working with is PHP and being as how I know "Nothing" abut PHP maybe i picked a bad starting point.  But it did so well with the CSS display characteristics i hated to give it up.  It reads every png file perfectly and puts the image right where it should.  But the code loads the png's actual "local drive" location to the a^href value.  I will try to attach it here in a sec and maybe you ca see where I am "blind"

« Last Edit: May 26, 2016, 09:12 PM by questorfla »

Target

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,832
    • View Profile
    • Donate to Member
Re: Using script to copy multiple image files to a page
« Reply #10 on: May 26, 2016, 09:07 PM »
Of course there may be simpler ways than playing around with Powershell, ie. write the output as a HTML doc then load into Word and save as a Word file.

I was thinking along the same lines.  I have a small script that does pretty much this already, and the output is printed to PDF

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
Re: Using script to copy multiple image files to a page
« Reply #11 on: May 26, 2016, 09:16 PM »
I will trade you mine for one that works :).
Actually, this one makes a very nice photo album!
It just wont allow me to load the a^href value read from the matching text file for each PNG

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
Re: Using script to copy multiple image files to a page
« Reply #12 on: May 27, 2016, 08:27 PM »
Thanks to all for the contributions to the problem.
I have the solution in hand just in time to enjoy the Memorial weekend. 
For anyone else who might ever try anything like this, there is one extremely important fact that was holding everything up.  If you happen to be a Die-Hard Google Chrome User as I am, it was something I had never thought about or needed till now.

But at some point in the past, Google Chrome has "Disabled" the capacity to download MHTML webpages even though you CAN choose that you want "SingleFile  Webpage Complete" format.  What you Get, though, is normal Html code which does NOT work for what I was trying to accomplish. 
This can be "fixed" (if one knows that it needs to be) in the flags area of Chrome.  Doing this made a much better solution to everything.  Html code will not support a "Single-file" option having image with embedded hyperlinks so I kept getting a half-solution no matter what was tried. MHTML is a perfect fit though.