Results 11 to 18 of 18
-
11th Jan 2012, 10:46 AM #11Member
hey man.. thanks for your time!
I have written my own bash script that does some automation. I need a script, php or bash one, which uploads image to your host and returns bbcode with 550px thumb. The thing is that I know bash a bit, but I have absolutely zero knowledge with php.
thanks again
cheers
-
11th Jan 2012, 02:48 PM #12MemberWebsite's:
ImageZilla.netNot a problem. So do you want remote upload or regular upload? or both?
-
11th Jan 2012, 03:11 PM #13Member
Well, whichever is easier for you to code. I have no special request there, but of course both options would be nice, the more the merrier
If you insist that I choose one, it would be remote upload, I guess
cheers
-
11th Jan 2012, 04:23 PM #14MemberWebsite's:
ImageZilla.netI'll get both going
-
11th Jan 2012, 04:33 PM #15Member
thanks once more
-
12th Jan 2012, 11:53 PM #16MemberWebsite's:
ImageZilla.netHere's a script tested working on linux. I'm not sure about windows but I dont think you should have any problems. One function is for urls and the other function is for files. If you run your own php scripts should be able to just drop the functions in. Let me know if there any problems.
UPDATED: V2
Code:<? function imagezilla_url($img_url){ $thsize = '300'; //valid sizes are 150, 250,300,450,550 pixels $img_url = urlencode($img_url); $url = "http://imagezilla.net/firefoxremote.php?thumbsize=$thsize&url=$img_url"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, trim($url)); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); preg_match("/(http:\/\/(?:\w+\.){0,1}imagezilla\.net\/thumbs\/.*?)'/i",$result,$tn); preg_match("/(http:\/\/(?:\w+\.){0,1}imagezilla\.net\/images\/.*?)'/i",$result,$lp); $link_code = ''; $tn = $tn[1]; $lp = $lp[1]; $lp = str_replace('/images/','/show/', $lp); $link_code .= "<a href='$lp'><img src='$tn'".'></a>'."\n"; //html $link_code .= '[img]'.$tn.'[/img]'."\n"; //bbcode return $link_code; //first line contains html code, second line contains bb code. Comment out the code you dont want. } function imagezilla_file($img_filename){ $thsize = '400'; // thumbnail size: must be between 150px and 550px. Default is 400px $adult = 1; //defaults to adult images, set it to 0 if you are uploading non-adult images $key = "7t7ung19lktujxqddsva7mgtnoi7u1i5"; $post = array('file'=> "@$img_filename",'apikey' => "$key",'thumbsize' => "$thsize",'adult'=>"$adult"); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://imagezilla.net/api.php"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); preg_match('/<thumbnail>(.*?)<\/thumbnail>/i',$result,$tn); preg_match('/<largepic>(.*?)<\/largepic>/i',$result,$lp); $link_code = ''; $tn = $tn[1]; $lp = $lp[1]; $link_code .= "<a href='$lp'><img src='$tn'".'></a>'."\n"; //html $link_code .= '[img]'.$tn.'[/img]'."\n"; //bbcode return $link_code; //first line contains html code, second line contains bb code. Comment out the code you dont want. } $image = $argv[1]; if (strpos($image, 'http://') === 0) { echo imagezilla_url($image); } else { echo imagezilla_file($image); } ?>
-
13th Jan 2012, 05:35 PM #17Member
You, sir are AWESOME
Works like a charm, thanks a lot!
If anyone else needs this script, and (like me) needs forum bbcode with thumbnail, just modify this line
PHP Code:$link_code .= '[img]'.$tn.'[/img]'."\n";
PHP Code:$link_code .= '[URL='.$lp.'][img]'.$tn.'[/img][/URL]'."\n";
Although the following line didn't work with remote upload, because remote function returns url with "/images/" instead of "/show/". That will work well when you post it on forum, thumbnail will be loaded, but when you'll click on it, original pic won't be loaded. I've tried changing "/images/" to "/show/", but it didn't work. Normal upload works fine.
One more question though, I've tried modifying the script to get input from bash like some guy posted HERE but of course, I failed
Is there a way to do that, so bash command would be something like
Code:php imagezilla.php my_image.jpg
Thanks again for everything!
Cheers
-
14th Jan 2012, 01:55 PM #18MemberWebsite's:
ImageZilla.netI've updated the script. Fixed the large picture url and added some code so that you can use it from the command line. If you give the script a url make it starts with "http://". Everything else that doesn't start with "http://" will be consider a file.
Let me know if there are any bugs. I haven't tested it.
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
[Need help] curl / php upload for mediafire?
By futureawesome in forum Web Development AreaReplies: 10Last Post: 13th Nov 2012, 12:50 PM -
[Buying] php cURL upload function only
By hihotfile in forum Marketplace (Buy, Sell and Trade)Replies: 1Last Post: 23rd Sep 2012, 02:27 PM -
Why curl ftp upload is so slowly?
By ebogus in forum Web Development AreaReplies: 0Last Post: 12th Jun 2012, 07:57 PM -
Upload to Share-online with cUrl
By skinner in forum Web Development AreaReplies: 9Last Post: 23rd Mar 2012, 01:52 AM -
[Hiring] PHP Curl upload/download functions
By coincoinwc in forum Completed TransactionsReplies: 1Last Post: 29th Sep 2011, 01:18 PM
themaCreator - create posts from...
Version 3.24 released. Open older version (or...