This has me confused because:
Code:
stardotstar@geko ~ $ file -bi /tmp/splash_daily.jpg Code:
stardotstar@geko ~ $ xloadimage -onroot /tmp/img.264c8bb569b018170488a59aa1 Code:
stardotstar@geko ~ $ file -bi /tmp/img.264c8bb569b018170488a59aa1 image/jpeg Without the file statement google gif works just fine: Code:
stardotstar@geko ~ $ ./backgrounder.2 http://www.google.com/ncr Will |
Strange, it is not quite doing what I expected. I'll try to summarise my findings and if you can see the benefit of pursuing it I appreciate it - but I understand the effort you have gone to already and don't want to turn this into a new sf project :)
I have removed the file removal so I can compare what is captured. It seems that anything except gifs get 0 file size and are unknown type. Here is the result of executing the script on several pages and the list of files generated, IBM and Google worked anything that found a png or jpg failed to write any content: Code:
stardotstar@geko ~ $ sh -x ./backgrounder.1 http://www.kernel.org 2>&1 Code:
stardotstar@geko ~ $ sh -x ./backgrounder.2 http://www.ibm.org 2>&1 so too below for google: Code:
stardotstar@geko ~ $ sh -x ./backgrounder.2 http://www.google.com/ncr 2>&1 Code:
stardotstar@geko ~ $ file -bi /tmp/img* Will UPDATE - I simplified the script further to try and see what was not working: Code:
stardotstar@geko ~ $ sh -x ./backgrounder.4 http://antwrp.gsfc.nasa.gov/apod/astropix.html |
"File" doesn't set anything, it just reads the MIME tag (in this case, due to -i). Egrep then (silently: -q) tries to match any string starting with "image/" and gi, jp or pn. "application/x-empty" means wget retrieved the file OK, but the file does not contain data. I'll cleanup some other stuff, rewrite in full and add comments. Note you loose PNG because xloadimage doesn't support it. You can of course always subsitute it for a loader that does. Also note you need to provide an URI in the format protocol://domain.tld/file.extension so protocol://domain.tld/ will not do. I could fix it by checking for and counting slashes or TLD position in "${uri:7}" and then not using "dirname" but not now. I also kept in recognition using "file" because I think that's the minimal check to do. I don't want to rely on extension alone.
Code:
#!/bin/sh |
Wow, thanks heaps. I really appreciate your taking the time to work on this project for me :) I am following the code and it is very informative - one day I hope to be able to tackle stuff like this.
I am still running into the zero size get problem. The astropix site is a good reference because they have only one pic and it changes from gif to jpg regularly which is the situation on my intranet (mainly catalogue pics that could be jpeg straight from a digital camera or gifs needing transparency for inclusion in a website. etc.) http://antwrp.gsfc.nasa.gov/apod/astropix.html I am using that for reference whilst at home over weekend at at nights because the intranet is not available. I find that I am still continually getting zero file sizes but when I point wget directly at the image link it works... Code:
geko stardotstar # xloadimage -onroot gcenter_2mass_big.jpg Code:
geko stardotstar # wget http://antwrp.gsfc.nasa.gov/apod/image/0607/gcenter_2mass_big.jpg Code:
geko stardotstar # sh -x /home/stardotstar/backgrounder.4 http://antwrp.gsfc.nasa.gov/apod/astropix.html BTW I have been prowling around sf and googling this type of solution and found chbg and such but they are not nearly as simple and convenient as this script. Will |
getImg.sh 1.4 (final)
I am still running into the zero size get problem.
That's because of how the img src links work, sometimes relative, sometimes full paths: Code:
./getImg-v2.sh http://www.google.com/ncr I've corrected that and added some checks. After testing with your submitted URI's I consider this somewhat "final" but it still isn't optimised etc, etc. Please respect the License and retain comment headers when using/distributing. Code:
#!/bin/bash * If you (stardotstar) want to do something in return (though no pressure, this script is provided for free so if you can't / won't I understand), then post the name of a (GNU/Linux distro-agnostic!) background image loader that does handle PNG and other image formats. That's all. Have fun! |
Of course I will respect the GPLv2 Licence and I am very appreciative of your efforts and insight into my particular problem. This, to me, is the very heart of the open source community spirit and I revere you for your skill and admire the willingness you exhibit in sharing it.
If I can find a programme which Quote:
Best Regards, Will.* |
This application is working a treat and I want first of all to thank you despawn for taking the time to develop it for me - and teaching me a new level in scripting. I am proud to say that this has led to my actually being able to demonstrate that I have *tried* to solve the current requirement I need to add to the script to finish it and make it match the windows clients...
The script currently loads the picture of the day perfectly (well I can't get it to work as well with multiple screens as Windows but that is way out of scope :lol: ) but the product or content is accompanied by a part number/name and description. I am trying to get ImageMagick to print the name of the image on the picture and have so far got it to print static text but can't get it to write the ${img} - which I think is what it should be... the relevant part is: Code:
addTitleText=$(convert -fill white -draw 'text 100,100 "${img}"' /tmp/img.$rand /tmp/titled 2>&1) I have also not been able to get convert to output over the top of the img.$rand or write *to* titled.$rand because of syntax problems (I must get a good tutorial on scripting). I also tried to echo the output of the file name to a text file with: 'text 100,100 ${img}' appended and then call that in the script with convert using the @ modifier. to no avail... I'm sure all this is just knowledge about how to insert variables in scripts with respect to "'\/ etc - makes my head spin :) Ideally if I can strip the .jpg or .gif or whatever off the name and print it on the image it will be adequete - I will work out how to add the comments later. Can I get some assistance with this please? This is the current full listing (you will see that I have butchered some of it ;) by writing the daily randomised file name to a wallpaper directory so the screensaver uses it, and removal of the titled temp file as well as the img.$rand at the end. Oh, and root tail since I can now use it with nautilus background management turned off :grin: Finally, can we not just use convert/ImageMagick to handle any file types that are not compatible with xloadimage??? That would satisfy the request you made in your last post? (just a thought>) Code:
#!/bin/bash |
OK by hacking around and talking to the windows developer I have made some progress:
I reset img early to newimg and use that to title the image with convert: Code:
# Strip the src= part. |
Code:
#!/bin/bash |
sorry i immediately pressed the submit button without even making an intro. i just made some modifications to the script above. hope you'll find it useful. nice script by the way unspawn.
|
Hi Konsolebox;
there seem to be some problems with this version: Code:
geko stardotstar # chmod a+x /usr/bin/getImg.sh Although this could be useful since there are applications that require selecting the correct image in this case I don't want any interactivity and the page I am grabbing from has only one image. (well it has been known to have mouseovers and the second one is desirable but that is out of scope for now :) ) Thank you for ocntributing I will continue to try and grok your additions and integrate them if I can ... Further to the zero image size problem the jpg in the above instance is also downloading as zero size... and yet it can be grabbed happily from browser etc... Code:
geko stardotstar # wget http://antwrp.gsfc.nasa.gov/apod/image/0607/PIA08576marsmeteorites45.jpg -O thisimage Code:
Will |
sorry about that. this should fix the problem now
Code:
#!/bin/bash |
Ahhhhh, big problem we have been having here is that some of the files that are not making it down have mixed lower and upper case in file name...
so: Code:
# Grab file and dump on stdout, make all lowercase, grep for HTML image tag, and only use first line. :) |
Good job there. :) Have you already tried my new mod? I've already tested the script and was able to download the image files properly. The reason why the script didn't work before is because of the uppercase IMG and SRC. And i have to use eval to reconstruct the statements removing the double quotes from being included in the variable's value.
But anyways. We already have two scripts here. So I hope you'll be successful building the rpm script. Best luck then. :) Edit: batch script I mean |
OK I am forging ahead with the title grabbing;
By modifying unspawn's greps and parsing I have managed to come up with a separate script that successfully looks for the first HTML <b> tag and head -1's that output from wget; then writes it to a text file which I try to strip the tags off... Code:
#!/bin/bash Code:
geko stardotstar # sh -x ./greptitle.sh http://antwrp.gsfc.nasa.gov/apod/astropix.html <b> Strangers on Mars </b> <br> almost gets properly formed - removing <b> and </b> <b > using tr (badly :lol: ) but I am left with the r which if I delete it ruins the text. What I need is a way now of stripping leading white space and *all* the tags after the first < I will keep hacking at it but I would appreciate some gentle nudges in the right direction. Because our team formats the intranet page that displays the pic of the day (actually based on a very similar layout to that astronomy page - because it is so simple - image, title and description) I am using the astronomy page as a reference - because it can be tested naturally. Will |
All times are GMT -5. The time now is 02:52 PM. |