Created
October 5, 2012 11:53
-
-
Save sorl/3839394 to your computer and use it in GitHub Desktop.
Synology thumbnail generation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <libgen.h> | |
#include <Magick++.h> | |
using namespace std; | |
using namespace Magick; | |
string out( string fn, string sz ) { | |
return "@eaDir/" + fn + "/SYNOPHOTO:THUMB_" + sz + ".jpg"; | |
} | |
int main( int, char **argv) { | |
InitializeMagick(*argv); | |
Image im; | |
string src = argv[1]; | |
string fn = string( basename( strdup( src.c_str() ) ) ); | |
struct th { | |
string geometry; | |
string size; | |
}; | |
th sizes [4] = { | |
{ "800x800>", "L" }, | |
{ "640x640>", "B" }, | |
{ "320x320>", "M" }, | |
{ "120x120>", "S" } | |
}; | |
im.read( src ); | |
im.scale("1280x1280>"); | |
im.unsharpmask(0.5, 0.5, 1.25, 0.0); | |
im.write( out( fn, "XL" ) ); | |
for ( int j=0; j<4; j++) { | |
im.scale( sizes[j].geometry ); | |
//cout << out( fn, sizes[j].size ) << endl; | |
im.write( out( fn, sizes[j].size ) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment