Skip to content

Instantly share code, notes, and snippets.

@sorl
Created October 5, 2012 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sorl/3839394 to your computer and use it in GitHub Desktop.
Save sorl/3839394 to your computer and use it in GitHub Desktop.
Synology thumbnail generation
#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