"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "f.batch.cc" between
fotoxx-22.41.tar.gz and fotoxx-22.50.tar.gz

About: fotoxx is a program for photo editing and collection management.

f.batch.cc  (fotoxx-22.41):f.batch.cc  (fotoxx-22.50)
skipping to change at line 32 skipping to change at line 32
m_batch_convert batch rename, convert, resize, move m_batch_convert batch rename, convert, resize, move
m_batch_copy_move batch copy/move selected files to another folder m_batch_copy_move batch copy/move selected files to another folder
m_batch_upright find rotated files and upright them m_batch_upright find rotated files and upright them
m_batch_deltrash delete or trash selected files m_batch_deltrash delete or trash selected files
m_batch_RAW convert RAW files to jpg/png/tif, 8/16 bits m_batch_RAW convert RAW files to jpg/png/tif, 8/16 bits
m_batch_overlay add overlay image (caption ...) to selected files m_batch_overlay add overlay image (caption ...) to selected files
m_burn_DVD burn images to DVD/Blue-Ray disc m_burn_DVD burn images to DVD/Blue-Ray disc
m_export_filelist select files and generate a file list (text) m_export_filelist select files and generate a file list (text)
m_export_files select files and export to a folder m_export_files select files and export to a folder
m_convert_adobe convert Adobe document file to set of jpeg files
m_edit_script edit a script file calling multiple edit functions m_edit_script edit a script file calling multiple edit functions
m_edit_script_addfunc edit_done() hook to insert dialog settings into scrip t m_edit_script_addfunc edit_done() hook to insert dialog settings into scrip t
m_run_script run script like edit function for current image file m_run_script run script like edit function for current image file
m_batch_script run script for batch of selected image files m_batch_script run script for batch of selected image files
******************************************************************************** */ ******************************************************************************** */
#define EX extern // enable extern declarations #define EX extern // enable extern declarations
#include "fotoxx.h" // (variables in fotoxx.h are refs) #include "fotoxx.h" // (variables in fotoxx.h are refs)
#include <sys/wait.h> #include <sys/wait.h>
/******************************************************************************* */ /******************************************************************************* */
// Batch file rename, convert, resize, move // Batch file rename, convert, resize, move
namespace batch_convert namespace batch_convert
{ {
int Fsametype, Fupsize, Fdownsize, maxww, maxhh; int Fsametype, Fupsize, Fdownsize, maxww, maxhh;
int Fsamebpc, newbpc, jpeg_quality; int Fsamebpc, newbpc, jpeg_quality;
int Fdelete, Fcopymeta, FuprightB, Freplace; int Fdelete, Fcopymeta, FuprightB, Freplace;
int Fnewtext;
int Fplugdate, Fplugseq, Fplugname; int Fplugdate, Fplugseq, Fplugname;
char text1[100], text2[100];
char newloc[500], newname[200], newext[8]; char newloc[500], newname[200], newext[8];
int baseseq, addseq; int baseseq, addseq;
int amount, thresh; int amount, thresh;
}; };
// menu function // menu function
void m_batch_convert(GtkWidget *, cchar *) void m_batch_convert(GtkWidget *, cchar *)
{ {
using namespace batch_convert; using namespace batch_convert;
skipping to change at line 103 skipping to change at line 104
} }
if (Fblock("batch_convert","block edits")) return; // check pending, block if (Fblock("batch_convert","block edits")) return; // check pending, block
/*** /***
______________________________________________________________ ______________________________________________________________
| Batch Convert | | Batch Convert |
| | | |
| [Select Files] N files selected | | [Select Files] N files selected |
| | | |
| New Name [________________________________________________] | | Replace Text [__________________] --> [__________________] |
replace substring in file names 22.50
| New Name [________________________________________________] |
$yyyy $mm $dd $oldname $ss
| Sequence Numbers base [_____] adder [____] | | Sequence Numbers base [_____] adder [____] |
| New Location [__________________________________] [browse] | | New Location [__________________________________] [browse] |
| | | |
| (o) tif (o) png (o) jpg [90] jpg quality (o) no change | | (o) tif (o) png (o) jpg [90] jpg quality (o) no change |
| Color Depth: (o) 8-bit (o) 16-bit (o) no change | | Color Depth: (o) 8-bit (o) 16-bit (o) no change |
| Max. Width [____] Height [____] [x] downsize [x] upsize | | Max. Width [____] Height [____] [x] downsize [x] upsize |
| [x] Delete Originals [x] Copy Metadata [x] Upright | | [x] Delete Originals [x] Copy Metadata [x] Upright |
| | | |
| [proceed] [cancel] | | [proceed] [cancel] |
|______________________________________________________________| |______________________________________________________________|
***/ ***/
zd = zdialog_new("Batch Convert",Mwin,"Proceed","Cancel",null); zd = zdialog_new("Batch Convert",Mwin,"Proceed","Cancel",null);
zdialog_add_widget(zd,"hbox","hbf","dialog",0,"space=5"); zdialog_add_widget(zd,"hbox","hbf","dialog",0,"space=5");
zdialog_add_widget(zd,"button","files","hbf","Select Files","space=5"); zdialog_add_widget(zd,"button","files","hbf","Select Files","space=5");
zdialog_add_widget(zd,"label","fcount","hbf","no files selected","space=10"); zdialog_add_widget(zd,"label","fcount","hbf","no files selected","space=10");
zdialog_add_widget(zd,"hbox","hbrep","dialog");
// 22.50
zdialog_add_widget(zd,"label","labrep1","hbrep","Replace Text","space=5");
zdialog_add_widget(zd,"zentry","text1","hbrep",0,"expand");
zdialog_add_widget(zd,"label","arrow","hbrep"," → ","space=5");
zdialog_add_widget(zd,"zentry","text2","hbrep",0,"expand");
zdialog_add_widget(zd,"hbox","hbname","dialog"); zdialog_add_widget(zd,"hbox","hbname","dialog");
zdialog_add_widget(zd,"label","labname","hbname","New Name","space=5"); zdialog_add_widget(zd,"label","labname","hbname","New Name","space=5");
zdialog_add_widget(zd,"zentry","newname","hbname",0,"expand"); zdialog_add_widget(zd,"zentry","newname","hbname",0,"expand");
zdialog_add_widget(zd,"hbox","hbseq","dialog"); zdialog_add_widget(zd,"hbox","hbseq","dialog");
zdialog_add_widget(zd,"label","labseq","hbseq","Sequence Numbers","space=5"); zdialog_add_widget(zd,"label","labseq","hbseq","Sequence Numbers","space=5");
zdialog_add_widget(zd,"label","space","hbseq",0,"space=8"); zdialog_add_widget(zd,"label","space","hbseq",0,"space=8");
zdialog_add_widget(zd,"label","labbase","hbseq","base","space=5"); zdialog_add_widget(zd,"label","labbase","hbseq","base","space=5");
zdialog_add_widget(zd,"zspin","baseseq","hbseq","0|100000|1|0","size=5"); zdialog_add_widget(zd,"zspin","baseseq","hbseq","0|100000|1|0","size=5");
zdialog_add_widget(zd,"label","space","hbseq","","space=3"); zdialog_add_widget(zd,"label","space","hbseq","","space=3");
skipping to change at line 245 skipping to change at line 253
outext = zstrdup(inext,"batch convert",4); outext = zstrdup(inext,"batch convert",4);
cc = strlen(outloc) - 1; // remove trailing '/' cc = strlen(outloc) - 1; // remove trailing '/'
if (outloc[cc] == '/') outloc[cc] = 0; if (outloc[cc] == '/') outloc[cc] = 0;
if (*newname) { if (*newname) {
zfree(outname); zfree(outname);
outname = zstrdup(newname,"batch convert"); // may contain $-plugins outname = zstrdup(newname,"batch convert"); // may contain $-plugins
} }
if (Fnewtext) {
// 22.50
tempname = zstrdup(outname,"batch convert",100);
repl_1str(outname,tempname,text1,text2);
// replace text1 (if present) with text2
zfree(outname);
outname = tempname;
}
if (Fplugname) // insert old file name if (Fplugname) // insert old file name
{ {
cc = strlen(outname) - 8 + strlen(inname); cc = strlen(outname) - 8 + strlen(inname);
if (cc < 1) cc = 1; if (cc < 1) cc = 1;
tempname = zstrdup(outname,"batch convert",cc); tempname = zstrdup(outname,"batch convert",cc);
repl_1str(outname,tempname,"$oldname",inname); // ...$oldname... >> ...inname... repl_1str(outname,tempname,"$oldname",inname); // ...$oldname... >> ...inname...
zfree(outname); zfree(outname);
outname = tempname; outname = tempname;
} }
skipping to change at line 530 skipping to change at line 545
zdialog_stuff(zd,"16-bit",0); zdialog_stuff(zd,"16-bit",0);
zdialog_stuff(zd,"samebpc",0); zdialog_stuff(zd,"samebpc",0);
zdialog_stuff(zd,"8-bit",1); zdialog_stuff(zd,"8-bit",1);
} }
// wait for dialog completion via [proceed] button // wait for dialog completion via [proceed] button
if (zd->zstat != 1) return 1; if (zd->zstat != 1) return 1;
zd->zstat = 0; // keep active until inputs OK zd->zstat = 0; // keep active until inputs OK
zdialog_fetch(zd,"text1",text1,100);
// text within file name 22.50
zdialog_fetch(zd,"text2",text2,100);
// replacement text
zdialog_fetch(zd,"newname",newname,200); // new file name zdialog_fetch(zd,"newname",newname,200); // new file name
zdialog_fetch(zd,"baseseq",baseseq); // base sequence number zdialog_fetch(zd,"baseseq",baseseq); // base sequence number
zdialog_fetch(zd,"addseq",addseq); // sequence number adder zdialog_fetch(zd,"addseq",addseq); // sequence number adder
zdialog_fetch(zd,"newloc",newloc,500); // new location (folder) zdialog_fetch(zd,"newloc",newloc,500); // new location (folder)
zdialog_fetch(zd,"maxww",maxww); // new max width zdialog_fetch(zd,"maxww",maxww); // new max width
zdialog_fetch(zd,"maxhh",maxhh); // new max height zdialog_fetch(zd,"maxhh",maxhh); // new max height
zdialog_fetch(zd,"downsize",Fdownsize); // downsize checkbox zdialog_fetch(zd,"downsize",Fdownsize); // downsize checkbox
zdialog_fetch(zd,"upsize",Fupsize); // upsize checkbox zdialog_fetch(zd,"upsize",Fupsize); // upsize checkbox
zdialog_fetch(zd,"jpgqual",jpeg_quality); // jpeg quality zdialog_fetch(zd,"jpgqual",jpeg_quality); // jpeg quality
skipping to change at line 563 skipping to change at line 580
zdialog_fetch(zd,"8-bit",ii); zdialog_fetch(zd,"8-bit",ii);
if (ii) newbpc = 8; if (ii) newbpc = 8;
zdialog_fetch(zd,"16-bit",ii); zdialog_fetch(zd,"16-bit",ii);
if (ii) newbpc = 16; if (ii) newbpc = 16;
if (! GScount) { if (! GScount) {
zmessageACK(Mwin,"no files selected"); zmessageACK(Mwin,"no files selected");
return 1; return 1;
} }
Fnewtext = 0;
// 22.50
if (*text1) Fnewtext = 1;
// replace text1 with text2 (may be null)
Fplugdate = Fplugseq = Fplugname = 0; Fplugdate = Fplugseq = Fplugname = 0;
strTrim2(newname); strTrim2(newname);
if (! blank_null(newname)) if (! blank_null(newname))
{ {
if (Fnewtext) {
// 22.50
zmessageACK(Mwin,"you cannot use new name and replace text together");
return 1;
}
pp = newname; pp = newname;
while ((pp = strchr(pp,'$'))) while ((pp = strchr(pp,'$')))
{ {
if (strmatchN(pp,"$yyyy",5)) Fplugdate = 1; // $yyyy if (strmatchN(pp,"$yyyy",5)) Fplugdate = 1; // $yyyy
else if (strmatchN(pp,"$mm",3)) Fplugdate = 1; // $mm else if (strmatchN(pp,"$mm",3)) Fplugdate = 1; // $mm
else if (strmatchN(pp,"$dd",3)) Fplugdate = 1; // $dd else if (strmatchN(pp,"$dd",3)) Fplugdate = 1; // $dd
else if (strmatchN(pp,"$s",2)) Fplugseq = 1; // $s...s (sequence number cc) else if (strmatchN(pp,"$s",2)) Fplugseq = 1; // $s...s (sequence number cc)
else if (strmatchN(pp,"$oldname",8)) Fplugname = 1; // $oldname else if (strmatchN(pp,"$oldname",8)) Fplugname = 1; // $oldname
else { else {
skipping to change at line 633 skipping to change at line 658
Freplace = 0; Freplace = 0;
if (*newname <= ' ' && *newloc <= ' ' && Fsametype) if (*newname <= ' ' && *newloc <= ' ' && Fsametype)
Freplace = 1; Freplace = 1;
if (Freplace && Fdelete) { // 22.11 if (Freplace && Fdelete) { // 22.11
zmessageACK(Mwin,"delete originals specified but no new name given"); zmessageACK(Mwin,"delete originals specified but no new name given");
return 1; return 1;
} }
/** Convert NN image files 0 /** Convert NN image files CF
Rename to xxxxxxx 1 Replace text: xxxx --> yyyy RT
Convert to .ext N-bits/color 2 2a // 22.50
Downsize within NNxNN 3 Rename to xxxxxxx RN
Upsize within NNxNN 3a Convert to .ext N-bits/color CX CXa
Output to /.../... 4 Downsize within NNxNN DZ
Copy Metadata Upright 5 Upsize within NNxNN UZ UZa
*** Delete Originals *** 6 Output to /.../... OP
*** Replace Originals *** 7 Copy Metadata Upright CM
PROCEED? 8 *** Delete Originals *** DO
*** Replace Originals *** RO
PROCEED? PR
**/ **/
char mess0[60], mess1[100], mess2[60], mess2a[60], mess3[60], mess3a[60], me char messCF[60], messRN[100], messRT[230], messCX[60], messCXa[60],
ss4[550], messDZ[60], messDZa[60], messOP[550], messCM[80], messDO[60],
mess5[80], mess6[60], mess7[60], mess8[40]; messRO[60], messPR[40];
char warnmess[1000]; char warnmess[1000];
*mess0 = *mess1 = *mess2 = *mess2a = *mess3 = *mess3a = *mess4 *messCF = *messRN = *messRT = *messCX = *messCXa = *messDZ = *messDZa
= *mess5 = *mess6 = *mess7 = *mess8 = 0; = *messOP = *messCM = *messDO = *messRO = *messPR = 0;
snprintf(mess0,60,"Convert %d image files",GScount); snprintf(messCF,60,"Convert %d image files",GScount);
if (*newname) snprintf(mess1,100,"\n %s %s","Rename to",newname); if (Fnewtext) snprintf(messRT,230,"\n Replace text: %s → %s",text1,text2);
if (! Fsametype) snprintf(mess2,60,"\n %s %s","Convert to",newext); // 22.50
if (! Fsamebpc) snprintf(mess2a,60,"\n %d-bits/color",newbpc); if (*newname) snprintf(messRN,100,"\n %s %s","Rename to",newname);
if (Fdownsize) snprintf(mess3,60,"\n %s %dx%d","Downsize within",maxww,maxhh if (! Fsametype) snprintf(messCX,60,"\n %s %s","Convert to",newext);
); if (! Fsamebpc) snprintf(messCXa,60,"\n %d-bits/color",newbpc);
if (Fupsize) snprintf(mess3a,60,"\n %s %dx%d","Upsize within",maxww,maxhh); if (Fdownsize) snprintf(messDZ,60,"\n %s %dx%d","Downsize within",maxww,maxh
if (*newloc) snprintf(mess4,550,"\n %s %s","Output to",newloc); h);
if (Fcopymeta || FuprightB) strcat(mess5,"\n "); if (Fupsize) snprintf(messDZa,60,"\n %s %dx%d","Upsize within",maxww,maxhh);
if (Fcopymeta) { strcat(mess5,"Copy Metadata"); strcat(mess5," "); } if (*newloc) snprintf(messOP,550,"\n %s %s","Output to",newloc);
if (FuprightB) { strcat(mess5,"Upright"); strcat(mess5," "); } if (Fcopymeta || FuprightB) strcat(messCM,"\n ");
if (Fdelete) snprintf(mess6,60,"\n %s","*** Delete Originals ***"); if (Fcopymeta) { strcat(messCM,"Copy Metadata"); strcat(messCM," "); }
if (Freplace) snprintf(mess7,60,"\n %s","*** Replace Originals ***"); if (FuprightB) { strcat(messCM,"Upright"); strcat(messCM," "); }
snprintf(mess8,40,"\n\n%s","PROCEED?"); if (Fdelete) snprintf(messDO,60,"\n %s","*** Delete Originals ***");
if (Freplace) snprintf(messRO,60,"\n %s","*** Replace Originals ***");
snprintf(warnmess,1000,"%s %s %s %s %s %s %s %s %s %s %s", snprintf(messPR,40,"\n\n%s","PROCEED?");
mess0,mess1,mess2,mess2a,mess3,mess3a,mess4,mess5,mess6,mess7,mess8)
; snprintf(warnmess,1000,"%s %s %s %s %s %s %s %s %s %s %s %s",
messCF, messRT, messRN, messCX, messCXa, messDZ, messDZa, messOP,
messCM, messDO, messRO, messPR);
yn = zmessageYN(Mwin,warnmess); yn = zmessageYN(Mwin,warnmess);
if (! yn) return 1; if (! yn) return 1;
zd->zstat = 1; // [proceed] zd->zstat = 1; // [proceed]
return 1; return 1;
} }
/******************************************************************************* */ /******************************************************************************* */
skipping to change at line 2494 skipping to change at line 2523
if (tolocation[cc] == '/') tolocation[cc] = 0; if (tolocation[cc] == '/') tolocation[cc] = 0;
zdialog_fetch(zd,"samesize",Fsamesize); // get resize options zdialog_fetch(zd,"samesize",Fsamesize); // get resize options
zdialog_fetch(zd,"maxww",maxww); zdialog_fetch(zd,"maxww",maxww);
zdialog_fetch(zd,"maxhh",maxhh); zdialog_fetch(zd,"maxhh",maxhh);
zdialog_fetch(zd,"meta",Fmeta); // metadata option zdialog_fetch(zd,"meta",Fmeta); // metadata option
return 1; return 1;
} }
/*******************************************************************************
*/
// Select an Adobe document file and convert all pages into jpeg image files.
// The image files are named InputFileName-N.jpg where N is the page number.
// File types recognized: .pdf .ps .eps
void m_convert_adobe(GtkWidget *, cchar *)
// 22.20
{
char *pp, *infile = 0, *outfile = 0;
zdialog *zd = 0;
int err, zstat, ww, dpi;
F1_help_topic = "convert adobe";
Plog(1,"convert adobe \n");
if (Fblock(0,"blocked edits")) return;
// check nothing pending
err = zshell(0,"which gs >/dev/null 2>&1");
// check ghostscript installed
if (err) {
zmessageACK(Mwin,"ghostscript must be installed");
goto returnx;
}
pp = 0;
if (navi::gallerytype == FOLDER) pp = navi::galleryname;
infile = zgetfile("Open Adobe File",MWIN,"file",pp);
if (! infile) goto returnx;
pp = strrchr(infile,'.');
if (! strcasestr(".pdf .ps .eps",pp)) {
zmessageACK(Mwin,"not an Adobe file (.pdf .ps .eps)");
goto returnx;
}
/***
______________________________________
| Convert Adobe Document |
| |
| File name: [______________________] |
| Page width: [___] pixels |
| |
| [OK] [Cancel] |
|______________________________________|
***/
zd = zdialog_new("Convert Adobe Document",Mwin,"OK","Cancel",null);
zdialog_add_widget(zd,"hbox","hbf","dialog",0,"space=2");
zdialog_add_widget(zd,"label","labf","hbf","File name:","space=3");
zdialog_add_widget(zd,"zentry","infile","hbf",0,"space=3");
zdialog_add_widget(zd,"hbox","hbww","dialog",0,"space=2");
zdialog_add_widget(zd,"label","labww","hbww","Page width:","space=3");
zdialog_add_widget(zd,"zspin","ww","hbww","100|10000|10|1000","space=3");
zdialog_add_widget(zd,"label","labpix","hbww","pixels","space=3");
pp = strrchr(infile,'/');
if (pp) pp++;
else pp = infile;
zdialog_stuff(zd,"infile",pp);
zdialog_resize(zd,400,0);
zdialog_run(zd,0,"parent");
zstat = zdialog_wait(zd);
if (zstat != 1) goto returnx;
zdialog_fetch(zd,"ww",ww);
outfile = zstrdup(infile,"convert adobe",12);
// file.pdf >> file-%d.jpg
pp = strrchr(outfile,'.');
if (! pp) goto returnx;
strcpy(pp,"-%d.jpg");
dpi = ww / 8.5 + 0.5;
// convert width to dots per inch
err = zshell("ack","gs -q -sDEVICE=jpeg -r%d -o \"%s\" \"%s\" ",
dpi, outfile, infile);
if (err) goto returnx;
strcpy(pp,"-1.jpg");
// open 1st output file
f_open(outfile,0,0,1,0);
m_viewmode(0,"G");
// show gallery at file position
returnx:
if (zd) zdialog_free(zd);
if (infile) zfree(infile);
if (outfile) zfree(outfile);
return;
}
/******************************************************************************* * /******************************************************************************* *
Build a script file with one or more predefined edit functions Build a script file with one or more predefined edit functions
that can be executed like a single edit function. that can be executed like a single edit function.
fotoxx.h: char scriptfile[200]; // current script file fotoxx.h: char scriptfile[200]; // current script file
FILE *script_fid; // script file FID FILE *script_fid; // script file FID
int Fscriptbuild; // flag, script build in progress int Fscriptbuild; // flag, script build in progress
***/ ***/
 End of changes. 14 change blocks. 
136 lines changed or deleted 74 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)