a-harvey 0 Posted November 9, 2018 Report Share Posted November 9, 2018 HiIs there any scripts that can apply alt tags to images.I have some code that downloads an image from a url and names it with a given name, I now need to write the Name also to the Alt Tag of the image. Is this possible anyone have any thoughts on how to do it. Many thanksAndrew Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted November 9, 2018 Report Share Posted November 9, 2018 Hey, You would need to use $scrape attribute and instead of src use alt navigate("http://ubotdocta.com/ubot-stealth-boot-camp/advanced-training/2016/12/10/ubot-boot-camp-advanced-the-define-command-making-custom-commands-and-functions/","Wait") wait for element(<id="site-info">,20,"Appear") set(#alt,$scrape attribute(<title="define command">,"alt"),"Global") alert(#alt) set(#A,"filename-{#alt}.png","Global") Regards,Nick 1 Quote Link to post Share on other sites
a-harvey 0 Posted November 13, 2018 Author Report Share Posted November 13, 2018 Hi Nick, So my current code is below, I presume I could just add a command into the download file section that also adds the alt tag from row,0or would I still need to set the command Alt ? many thanks Andrew clear table(&images)create table from file("C:\\Users\\Andrew\\Desktop\\silverim.csv",&images)set(#row,0,"Global")create folder($special folder("Desktop"),"Silverstone Images")set(#path,"{$special folder("Desktop")}/Silverstone Images/","Global")loop($table total rows(&images)) { download file($table cell(&images,#row,1),"{#path}{$table cell(&images,#row,0)}.jpg") increment(#row)} Quote Link to post Share on other sites
a-harvey 0 Posted November 13, 2018 Author Report Share Posted November 13, 2018 FIO my sliverim.csv folder that I pull into the table hasnew name and url in it so I grab the image from the url and apply the name, so just need to apply the same name to the alt tag. I don't want to scrape the current alt tag, just write to it as I am when downloading and naming the image. hope that makes sense. Quote Link to post Share on other sites
HelloInsomnia 1103 Posted November 13, 2018 Report Share Posted November 13, 2018 If you mean the metadata you can use this: http://wiki.ubotstudio.com/wiki/Edit_jpeg_metadata I think that the image commands don't work in compiled though, in that case you can call Image Magick directly via command line arguments: https://imagemagick.org/script/command-line-processing.php 1 Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted November 13, 2018 Report Share Posted November 13, 2018 No, not really, I am more confused now. You want to name the image file url-new_name.jpg or change the metadata? The file name you can concatenate however you wish.Show an example of what your csv file row isand show an example of the output you would like. csv row http://ubotdocta.com,keyword(alt- tag)renamed fileubotdocta.com-keyword.jpg While downloading the file you can name it whatever you wish instead of making another loop. Unless it is a ton of images. Then you will run out of memory. Regards,Nick Quote Link to post Share on other sites
a-harvey 0 Posted November 13, 2018 Author Report Share Posted November 13, 2018 No its the meta data I want to amend also. File name is all sorted and working fine, its apply the same file name from my csv as I am to the downloaded image also to the metadata. sorry for any confusion. Quote Link to post Share on other sites
a-harvey 0 Posted November 13, 2018 Author Report Share Posted November 13, 2018 HelloInsomnia ,you are correct its the metadata I am now trying to apply, the file download and re-name to what I specify is working great, I just wanted to if possible add another feature which was to put the title "which is what I am naming the downloaded image" into the metadata. Quote Link to post Share on other sites
a-harvey 0 Posted November 13, 2018 Author Report Share Posted November 13, 2018 Nick, There are thousands of images pulled at any one time.FIO they are all named 0.jpg or 1.jpg so they need to be pulled and named Lot_x"title".jpg and cycle through them all, that is working fine with the above, I just wanted to then quickly if possible at the same time write to the metadata the same naming I am doing to the image. Hope that is more clear.many thanksAndrew Quote Link to post Share on other sites
a-harvey 0 Posted November 14, 2018 Author Report Share Posted November 14, 2018 Cannot get my head around specifying the image location, which has just been created -ahahahhahaahah Quote Link to post Share on other sites
HelloInsomnia 1103 Posted November 14, 2018 Report Share Posted November 14, 2018 Cannot get my head around specifying the image location, which has just been created -ahahahhahaahah Are you referring to the path of the image? Quote Link to post Share on other sites
a-harvey 0 Posted November 15, 2018 Author Report Share Posted November 15, 2018 Yes the path of where the image will be, as I will be downloading them one by one,so the path is set by the table in the code also the name is being set as its the same name as what I am naming the image. Hope that follows : Currently the code takes the url in coll 1 / downloads it to folder "Silverstone Images" on the desktop and gives it the name specified in coll 0I need to work out the required code to tell it that "this images just downloaded from the specifications given is located here. and apply the same name from the table to the meta data comment. I am going through the table one image at a time and downloading and naming, maybe its not possible to add the meta data as it downloads each image, maybe I have to download them all then create a new table with the image location and name and cycle through them adding the meta comment. That maybe a simpler way to do it, as I know what they will be called and where they will be, so maybe I just create another csv with that data and pull that into a new table after it has finshed downloading them all and then get it to apply the meta comment. clear table(&images)create table from file("C:\\Users\\Andrew\\Desktop\\silverim.csv",&images)set(#row,0,"Global")create folder($special folder("Desktop"),"Silverstone Images")set(#path,"{$special folder("Desktop")}/Silverstone Images/","Global")loop($table total rows(&images)) { download file($table cell(&images,#row,1),"{#path}{$table cell(&images,#row,0)}.jpg") increment(#row)} Quote Link to post Share on other sites
HelloInsomnia 1103 Posted November 15, 2018 Report Share Posted November 15, 2018 So it is naming and downloading them correctly right?You just now want to apply metadata to the image? If that's the case I took a quick peek and it looks like maybe this tool will do the job: https://www.sno.phy.queensu.ca/~phil/exiftool/ It has command line options so you can call it using the shell command. if you look at the examples for the first one here: https://www.sno.phy.queensu.ca/~phil/exiftool/exiftool_pod.html#WRITING-EXAMPLES You could do something like this: clear table(&images) create table from file("C:\\Users\\Andrew\\Desktop\\silverim.csv",&images) set(#row,0,"Global") create folder($special folder("Desktop"),"Silverstone Images") set(#path,"{$special folder("Desktop")}/Silverstone Images/","Global") loop($table total rows(&images)) { set(#saveImagePath,"{#path}{$table cell(&images,#row,0)}.jpg","Global") download file($table cell(&images,#row,1),#saveImagePath) shell("exiftool -Comment=\'This is a new comment\' {#saveImagePath}") increment(#row) } Quote Link to post Share on other sites
a-harvey 0 Posted November 16, 2018 Author Report Share Posted November 16, 2018 Many thanks Naming and downloading is correct yes "that side is working perfect" I have looked at that tool about 3 years ago, thank you for reminding me of it.I can get it to do everything but it is just clearing all existing the metadata and not writing anything to it.hmhmhmhm path seems correct as it is now finding and wiping the data but won't write the comment will look into the tool again and see if I can figure out why its not now writing the updated info. Quote Link to post Share on other sites
a-harvey 0 Posted November 16, 2018 Author Report Share Posted November 16, 2018 Yes strange, I cannot get it to apply any metadata to the images, it just removes what is already there, even if I specify the exact image and location as a single functionhmmmmmmm Quote Link to post Share on other sites
a-harvey 0 Posted January 3, 2019 Author Report Share Posted January 3, 2019 (edited) Ok so I have finally got my head around the exif tool and the commands that I use to do what I need are below and do exactly what I am after on a folder of files, ie will be the download images from the above bot. What would the command be to enable ubot to action the commands below from within UBot so I don't have to apply them outside Ubot. So not to confuse, the current Ubot, just downloads and names the files based on a csv, I want to after it has finished downloading all the images at that stage run these commends Many thanks Andrew: perl c:\windows\exiftool.pl -P -r "-title<${filename;s/\.[^\.]+$ //;s/[-]/ /g;s/_/ /}"" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\testimageperl c:\windows\exiftool.pl -artist="Silverstone Auctions" -copyright="2019 Silverstone Auctions" C:\Users\Andrew\Desktop\testimageperl c:\windows\exiftool.pl -subject="Silverstone Auctions AUTOSPORT INTERNATIONAL SHOW SALE 12th January 2019" C:\Users\Andrew\Desktop\testimageperl c:\windows\exiftool.pl -creator="Silverstone Auctions" C:\Users\Andrew\Desktop\testimageperl c:\windows\exiftool.pl -P -r "-description<${filename;s/\.[^\.]+$ //;s/[-]/ /g;s/_/ /}"" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\testimageperl c:\windows\exiftool.pl -P -r "-IFD0:XPSubject<${filename;s/\.[^\.]+$ //;s/[-]/ /g;s/_/ /}"" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\testimageperl c:\windows\exiftool.pl -P -r "-IFD0:XPComment<${filename;s/\.[^\.]+$ //;s/[-]/ /g;s/_/ /}"" -r -sep " " -ext jpg C:\Users\Andrew\Desktop\testimage Edited January 3, 2019 by a-harvey Quote Link to post Share on other sites
HelloInsomnia 1103 Posted January 3, 2019 Report Share Posted January 3, 2019 You can use the shell command: http://wiki.ubotstudio.com/wiki/Shell But you may also ant to check out the advanced shell plugin: http://network.ubotstudio.com/forum/index.php/topic/13798-free-plugin-advanced-shell/ 1 Quote Link to post Share on other sites
a-harvey 0 Posted January 3, 2019 Author Report Share Posted January 3, 2019 Thank you the plugin works great.adding now to my main Ubot but all seems to be working well, many thanks.Andrew Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted January 4, 2019 Report Share Posted January 4, 2019 You can do this with ubot edit jpeg metadata("","","") if you are subscribed Public bot bank>>image commands and there is a function to read metadata too Regards,Nick 1 Quote Link to post Share on other sites
a-harvey 0 Posted February 21, 2019 Author Report Share Posted February 21, 2019 Thanks Nick, I will look at this also, yes I am subscribed.I might be able to use that function, to grab the metadata after written and use that as a way to populate a instagram upload "ie the title etc" Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.