.



on-line?
? ?
Ru.Board » » » Image Uploader by ZendeN

: gyra, Maz

   •

     

Alex_Qwerty

Silver Member
| | | |


:
 
<Server Name="ipic.su (recompress test)" Plugin="ipic_su_recompress" MaxFileSize="3145728" Debug="0">
<Result ImageUrlTemplate="$(Image)" ThumbUrlTemplate="$(Thumb)" />
</Server>
 

 
ipic_su_recompress.nut:

:
 
function  UploadFile(FileName, options)
{
 
    // !?
function writelog(data) {
local mylog = file("mylog.log","ab");
data = "" + data;// tostring
    local b = blob(data.len());
    for(local i=0; i<data.len(); i++) { b[i]=data[i]; };
    mylog.writeblob(b);
    b = blob(2);
    b[0] = 13;
    b[1] = 10;
    mylog.writeblob(b);
    }
 
//system("cmd")
//system("C:\\WINDOWS\\system32\\notepad.exe")
 
function getFileSize(filename) {
    local f = file(filename,"rb");
    return f.len(); // There is no function to close the file?
    }
 
writelog("-----------------------------------------------------------------")
 
//local newName = FileName + ".jpg";
local newName = getenv("TEMP") + "\\tmd_iu_temp\\" + ExtractFileName(FileName) + ".jpg";
 
writelog("FileName="+FileName);
writelog("newName="+newName);
 
system("gm convert -sampling-factor 4:4:4 -quality 86 " + FileName + " " + newName);
 
local oldLength = getFileSize(FileName)
local newLength = getFileSize(newName)
 
writelog("oldLength="+oldLength);
writelog("newLength="+newLength);
 
local selectedFile = (oldLength/newLength >=2) ? newName : FileName;
 
nm.setUrl("http://ipic.su/");
nm.addQueryParam("link","/");
nm.addQueryParam("action","loadimg");
nm.addQueryParam("client","ipic.su");
nm.addQueryParamFile("image",selectedFile, ExtractFileName(selectedFile),"");
nm.addQueryParam("name","");
nm.addQueryParam("desc","");
nm.addQueryParam("origin","on");
nm.addQueryParam("cropselect","800");
nm.addQueryParam("quality","85");
nm.doUploadMultipartData();
 
local data = nm.responseBody();
 
local ex = regexp("\\[url=(.*)\\]\\[img\\](.*)\\[/img\\]\\[/url\\]");
local res = ex.capture(data, 0);
if(res == null){ return 0 }
local directUrl = "";
local thumbUrl = "";
directUrl = data.slice(res[1].begin, res[1].end);
thumbUrl = data.slice(res[2].begin, res[2].end);
options.setDirectUrl(directUrl);
options.setThumbUrl(thumbUrl);
return 1;
}
 

 

: 2088 | . 09-09-2006 | : 13:36 18-09-2011 | : Alex_Qwerty, 13:12 20-09-2011
     


Ru.Board » » » Image Uploader by ZendeN


Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.Board
© Ru.Board 2000-2020

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

.ru