"Fossies" - the Fresh Open Source Software Archive  

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

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

f.batch.cc  (fotoxx-23.0):f.batch.cc  (fotoxx-23.1)
/******************************************************************************* * /******************************************************************************* *
Fotoxx edit photos and manage collections Fotoxx - edit photos and manage collections
Copyright 2007-2023 Michael Cornelison Copyright 2007-2023 Michael Cornelison
source code URL: https://kornelix.net source code URL: https://kornelix.net
contact: mkornelix@gmail.com contact: mkornelix@gmail.com
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. See https://www.gnu.org/licenses (at your option) any later version. See https://www.gnu.org/licenses
skipping to change at line 54 skipping to change at line 54
// 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 Fnewtext;
int Fplugdate, Fplugseq, Fplugname; int Fplugdate, Fplugseq, Fplugname;
char text1[100], text2[100]; ch text1[100], text2[100];
char newloc[500], newname[200], newext[8]; ch 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 *, ch *)
{ {
using namespace batch_convert; using namespace batch_convert;
int batch_convert_dialog_event(zdialog *zd, cchar *event); int batch_convert_dialog_event(zdialog *zd, ch *event);
zdialog *zd, *zd2; zdialog *zd, *zdpop;
int zstat; int zstat;
char *infile, *outfile, tempfile[300]; ch *infile, *outfile, tempfile[300];
char *inloc, *inname, *inext; ch *inloc, *inname, *inext;
char *outloc, *outname, *outext; ch *outloc, *outname, *outext;
char *tempname, seqplug[8], seqnum[8]; ch *tempname, seqplug[8], seqnum[8];
char plugyyyy[8], plugmm[4], plugdd[4]; ch plugyyyy[8], plugmm[4], plugdd[4];
char **oldfiles, **newfiles; ch **oldfiles, **newfiles;
char *pp, *pp1, *ppv[2], text[100]; ch *pp, *pp1, *ppv[2], text[100];
int ii, jj, cc, err, Fjpeg; int ii, jj, cc, err, Fjpeg;
int outww, outhh, outbpc, Fdelete2; int outww, outhh, outbpc, Fdelete2;
int Noldnew; int Noldnew;
float scale, wscale, hscale; float scale, wscale, hscale;
PXM *pxmin, *pxmout; PXM *pxmin, *pxmout;
xxrec_t *xxrec; xxrec_t *xxrec;
cchar *exifkey[1] = { exif_orientation_key }; ch *metakey[1] = { meta_orientation_key };
cchar *exifdata[1]; ch *metadata[1];
char orient; ch orient;
F1_help_topic = "batch convert"; F1_help_topic = "batch convert";
Plog(1,"m_batch_convert \n"); Plog(1,"m_batch_convert \n");
if (Findexvalid == 0) { if (Findexvalid == 0) {
zmessageACK(Mwin,"image index disabled"); // no image index zmessageACK(Mwin,"image index disabled"); // no image index
return; return;
} }
skipping to change at line 215 skipping to change at line 215
zdialog_restore_inputs(zd); // preload prior user inputs zdialog_restore_inputs(zd); // preload prior user inputs
zdialog_run(zd,batch_convert_dialog_event,"parent"); // run dialog zdialog_run(zd,batch_convert_dialog_event,"parent"); // run dialog
zstat = zdialog_wait(zd); // wait for completion zstat = zdialog_wait(zd); // wait for completion
zdialog_free(zd); zdialog_free(zd);
if (zstat != 1) goto cleanup; // canceled if (zstat != 1) goto cleanup; // canceled
if (! GScount) goto cleanup; if (! GScount) goto cleanup;
free_resources(); // no curr. file free_resources(); // no curr. file
if (Fdelete) { if (Fdelete) {
cc = GScount * sizeof(char *); cc = GScount * sizeof(ch *);
// input files are to be deleted: // input files are to be deleted:
oldfiles = (char **) zmalloc(cc,"batch convert"); oldfiles = (ch **) zmalloc(cc,"batch convert");
// reserve space to hold list of // reserve space to hold list of
newfiles = (char **) zmalloc(cc,"batch convert"); newfiles = (ch **) zmalloc(cc,"batch convert");
// old/new filespecs to update albums // old/new filespecs to update albums
} }
zd2 = popup_report_open("Processing files",Mwin,600,300,0,0,"OK",0); // log report 22.15 zdpop = popup_report_open("Processing files",Mwin,600,300,0,0,"OK",0); // log report 22.15
for (ii = 0; ii < GScount; ii++) // loop selected files for (ii = 0; ii < GScount; ii++) // loop selected files
{ {
zmainloop(); // keep GTK alive zmainloop(); // keep GTK alive
if (zd2->zstat) break; // function canceled if (! zdialog_valid(zdpop)) break; // report canceled 23.1
infile = GSfiles[ii]; // input file infile = GSfiles[ii]; // input file
popup_report_write2(zd2,0,"\n"); popup_report_write2(zdpop,0,"\n");
popup_report_write2(zd2,0,"%s \n",infile); popup_report_write2(zdpop,0,"%s \n",infile);
// log each input file // log each input file
if (image_file_type(infile) != IMAGE) { if (image_file_type(infile) != IMAGE) {
popup_report_write2(zd2,0,"*** invalid file \n"); popup_report_write2(zdpop,0,"*** invalid file \n");
continue; continue;
} }
parsefile(infile,&inloc,&inname,&inext); // parse folder, filename, .ext parsefile(infile,&inloc,&inname,&inext); // parse folder, filename, .ext
if (! inloc || ! inname || ! inext) continue; if (! inloc || ! inname || ! inext) continue;
outloc = zstrdup(inloc,"batch convert"); // initial output = input file outloc = zstrdup(inloc,"batch convert"); // initial output = input file
outname = zstrdup(inname,"batch convert"); outname = zstrdup(inname,"batch convert");
outext = zstrdup(inext,"batch convert",4); outext = zstrdup(inext,"batch convert",4);
skipping to change at line 270 skipping to change at line 270
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;
} }
if (Fplugdate) // insert EXIF date if (Fplugdate) // insert meta date
{ {
xxrec = get_xxrec(infile); // get photo date, yyyymmddhhmmdd xxrec = get_xxrec(infile); // get photo date, yyyymmddhhmmdd
if (strmatch(xxrec->pdate,"null")) { if (strmatch(xxrec->pdate,"null")) {
popup_report_write2(zd2,0,"no photo date, skipped \n"); popup_report_write2(zdpop,0,"no photo date, skipped \n");
zfree(outloc); zfree(outloc);
zfree(outname); zfree(outname);
zfree(outext); zfree(outext);
continue; continue;
} }
strncpy0(plugyyyy,xxrec->pdate,5); // yyyy strncpy0(plugyyyy,xxrec->pdate,5); // yyyy
strncpy0(plugmm,xxrec->pdate+4,3); // mm strncpy0(plugmm,xxrec->pdate+4,3); // mm
strncpy0(plugdd,xxrec->pdate+6,3); // dd strncpy0(plugdd,xxrec->pdate+6,3); // dd
tempname = zstrdup(outname,"batch convert",8); tempname = zstrdup(outname,"batch convert",8);
skipping to change at line 319 skipping to change at line 319
} }
if (Fsametype) { // new .ext = existing .ext 22.11 if (Fsametype) { // new .ext = existing .ext 22.11
if (strcasestr(".jpg .jpeg .png .tif .tiff",inext)) if (strcasestr(".jpg .jpeg .png .tif .tiff",inext))
strcpy(outext,inext); strcpy(outext,inext);
else strcpy(outext,".jpg"); // unknown >> .jpg else strcpy(outext,".jpg"); // unknown >> .jpg
} }
else strcpy(outext,newext); // new .ext was given else strcpy(outext,newext); // new .ext was given
cc = strlen(outloc) + strlen(outname) + strlen(outext) + 4; // construct output file name cc = strlen(outloc) + strlen(outname) + strlen(outext) + 4; // construct output file name
outfile = (char *) zmalloc(cc,"batch convert"); outfile = (ch *) zmalloc(cc,"batch convert");
snprintf(outfile,cc,"%s/%s%s",outloc,outname,outext); snprintf(outfile,cc,"%s/%s%s",outloc,outname,outext);
Fjpeg = 0; Fjpeg = 0;
if (strmatch(outext,".jpg")) Fjpeg = 1; if (strmatch(outext,".jpg")) Fjpeg = 1;
zfree(outloc); zfree(outloc);
zfree(outname); zfree(outname);
zfree(outext); zfree(outext);
pxmin = PXM_load(infile,0); // read input file pxmin = PXM_load(infile,0); // read input file
if (! pxmin) { if (! pxmin) {
popup_report_write2(zd2,1,"file type not supported: %s \n",inext); popup_report_write2(zdpop,1,"file type not supported: %s \n",inext);
zfree(outfile); zfree(outfile);
continue; continue;
} }
popup_report_write2(zd2,0,"%s \n",outfile); // log each output file popup_report_write2(zdpop,0,"%s \n",outfile); // log each output file
if (*newloc) { if (*newloc) {
if (regfile(outfile)) { // check if file exists in new location if (regfile(outfile)) { // check if file exists in new location
popup_report_write2(zd2,1,"output file exists \n"); popup_report_write2(zdpop,1,"output file exists \n");
zfree(outfile); zfree(outfile);
continue; continue;
} }
} }
if (FuprightB) // upright image if turned if (FuprightB) // upright image if turned
{ {
exif_get(infile,exifkey,ppv,1); // get EXIF: Orientation meta_get1(infile,(ch **) metakey,ppv,1); // get metadata Orientation
if (ppv[0]) { if (ppv[0]) {
orient = *ppv[0]; orient = *ppv[0];
zfree(ppv[0]); zfree(ppv[0]);
pxmout = 0; pxmout = 0;
if (orient == '6') if (orient == '6')
pxmout = PXM_rotate(pxmin,+90); // rotate clockwise 90 deg. pxmout = PXM_rotate(pxmin,+90); // rotate clockwise 90 deg.
if (orient == '8') if (orient == '8')
pxmout = PXM_rotate(pxmin,-90); // counterclockwise 90 deg. pxmout = PXM_rotate(pxmin,-90); // counterclockwise 90 deg.
if (orient == '3') if (orient == '3')
pxmout = PXM_rotate(pxmin,180); // 180 deg. pxmout = PXM_rotate(pxmin,180); // 180 deg.
skipping to change at line 381 skipping to change at line 381
if (Fjpeg) outbpc = 8; // if jpeg, force 8 bits/color if (Fjpeg) outbpc = 8; // if jpeg, force 8 bits/color
if (Fdownsize) // downsize larger images if (Fdownsize) // downsize larger images
{ {
wscale = hscale = 1.0; wscale = hscale = 1.0;
if (outww > maxww) wscale = 1.0 * maxww / outww; // compute new size if (outww > maxww) wscale = 1.0 * maxww / outww; // compute new size
if (outhh > maxhh) hscale = 1.0 * maxhh / outhh; if (outhh > maxhh) hscale = 1.0 * maxhh / outhh;
if (wscale < hscale) scale = wscale; // scale < 1 if (wscale < hscale) scale = wscale; // scale < 1
else scale = hscale; else scale = hscale;
if (scale < 1.0) { if (scale < 1.0) {
outww = outww * scale; outww = outww * scale + 0.5;
outhh = outhh * scale; // round 23.1
outhh = outhh * scale + 0.5;
pxmout = PXM_rescale(pxmin,outww,outhh); // rescaled output file pxmout = PXM_rescale(pxmin,outww,outhh); // rescaled output file
PXM_free(pxmin); PXM_free(pxmin);
pxmin = 0; pxmin = 0;
} }
} }
if (Fupsize && pxmin) // upsize smaller images 22.11 if (Fupsize && pxmin) // upsize smaller images 22.11
{ {
wscale = hscale = 1.0; wscale = hscale = 1.0;
if (outww < maxww) wscale = 1.0 * maxww / outww; // compute new size if (outww < maxww) wscale = 1.0 * maxww / outww; // compute new size
if (outhh < maxhh) hscale = 1.0 * maxhh / outhh; if (outhh < maxhh) hscale = 1.0 * maxhh / outhh;
if (wscale < hscale) scale = wscale; // scale > 1 if (wscale < hscale) scale = wscale; // scale > 1
else scale = hscale; else scale = hscale;
if (scale > 1.0) { if (scale > 1.0) {
outww = outww * scale; outww = outww * scale + 0.5;
outhh = outhh * scale; // round 23.1
outhh = outhh * scale + 0.5;
pxmout = PXM_rescale(pxmin,outww,outhh); // rescaled output file pxmout = PXM_rescale(pxmin,outww,outhh); // rescaled output file
PXM_free(pxmin); PXM_free(pxmin);
pxmin = 0; pxmin = 0;
} }
} }
if (pxmin) { // no size change if (pxmin) { // no size change
pxmout = pxmin; pxmout = pxmin;
pxmin = 0; pxmin = 0;
} }
pp1 = strrchr(outfile,'/'); // get filename.ext pp1 = strrchr(outfile,'/'); // get filename.ext
if (pp1) pp1++; if (pp1) pp1++;
else pp1 = outfile; else pp1 = outfile;
snprintf(tempfile,300,"%s/%s",temp_folder,pp1); // temp file for EXIF/IPTC copy snprintf(tempfile,300,"%s/%s",temp_folder,pp1); // temp file for meta copy
err = PXM_save(pxmout,tempfile,outbpc,jpeg_quality,0); // write output image to temp file err = PXM_save(pxmout,tempfile,outbpc,jpeg_quality,0); // write output image to temp file
if (err) { if (err) {
popup_report_write2(zd2,1,"cannot create new file \n"); popup_report_write2(zdpop,1,"cannot create new file \n");
zfree(outfile); zfree(outfile);
PXM_free(pxmout); PXM_free(pxmout);
continue; continue;
} }
if (Fcopymeta) // copy EXIF/IPTC if requested if (Fcopymeta) // copy meta if requested
{ {
if (FuprightB) { // if image possibly uprighted if (FuprightB) { // if image possibly uprighted
exifdata[0] = ""; metadata[0] = 0;
// remove exif:orientation // remove metadata orientation
err = exif_copy(infile,tempfile,exifkey,exifdata,1); err = meta_copy(infile,tempfile,(ch **) metakey,metadata,1);
// (set = 1 does not work) // (set = 1 does not work)
} }
else err = exif_copy(infile,tempfile,0,0,0); else err = meta_copy(infile,tempfile,0,0,0);
// else no EXIF change // else no metadata change
if (err) popup_report_write2(zd2,1,"exif update error \n"); if (err) popup_report_write2(zdpop,1,"metadata update error \n");
// 23.0 // 23.0
} }
err = cp_copy(tempfile,outfile); // copy tempfile to output file err = cp_copy(tempfile,outfile); // copy tempfile to output file
if (err) popup_report_write2(zd2,1,"%s \n",strerror(err)); if (err) popup_report_write2(zdpop,1,"%s \n",strerror(err));
remove(tempfile); // remove tempfile remove(tempfile); // remove tempfile
Fdelete2 = 0; // figure out if input file can be deleted Fdelete2 = 0; // figure out if input file can be deleted
if (Fdelete) Fdelete2 = 1; // user says yes if (Fdelete) Fdelete2 = 1; // user says yes
if (err) Fdelete2 = 0; // not if error if (err) Fdelete2 = 0; // not if error
if (strmatch(infile,outfile)) Fdelete2 = 0; // not if overwritten by output if (strmatch(infile,outfile)) Fdelete2 = 0; // not if overwritten by output
if (Fdelete2) // delete input file if (Fdelete2) // delete input file
err = f_remove(infile,"delete"); // file/index/thumb/gallery err = f_remove(infile,"delete"); // file/index/thumb/gallery
skipping to change at line 461 skipping to change at line 461
if (Fdelete2) { // if input file was deleted, if (Fdelete2) { // if input file was deleted,
oldfiles[Noldnew] = zstrdup(infile,"batch convert"); // mark for updating albums oldfiles[Noldnew] = zstrdup(infile,"batch convert"); // mark for updating albums
newfiles[Noldnew] = zstrdup(outfile,"batch convert"); newfiles[Noldnew] = zstrdup(outfile,"batch convert");
Noldnew++; Noldnew++;
} }
zfree(outfile); zfree(outfile);
PXM_free(pxmout); PXM_free(pxmout);
} }
if (Noldnew) { if (! zdialog_valid(zdpop)) {
// update albums for renamed/moved files // 23.1
popup_report_write2(zd2,0,"updating albums ... \n"); Plog(0,"*** report cancelled \n");
album_purge_replace("ALL",Noldnew,oldfiles,newfiles); goto cleanup;
} }
if (zd2->zstat) popup_report_write2(zd2,0,"\n *** function canceled \n"); popup_report_write2(zdpop,0,"\n *** COMPLETED \n");
else popup_report_write2(zd2,0,"\n *** COMPLETED \n"); popup_report_bottom(zdpop);
popup_report_bottom(zd2);
cleanup: cleanup:
if (Noldnew) { if (Noldnew) {
for (ii = 0; ii < Noldnew; ii++) { for (ii = 0; ii < Noldnew; ii++) {
zfree(oldfiles[ii]); zfree(oldfiles[ii]);
zfree(newfiles[ii]); zfree(newfiles[ii]);
} }
zfree(oldfiles); zfree(oldfiles);
zfree(newfiles); zfree(newfiles);
skipping to change at line 492 skipping to change at line 491
gallery(navi::galleryname,"init",0); // refresh file list gallery(navi::galleryname,"init",0); // refresh file list
gallery(0,"sort",-2); // recall sort and position gallery(0,"sort",-2); // recall sort and position
gallery(0,"paint",-1); // repaint from same position gallery(0,"paint",-1); // repaint from same position
Fblock("batch_convert",0); Fblock("batch_convert",0);
return; return;
} }
// dialog event and completion callback function // dialog event and completion callback function
int batch_convert_dialog_event(zdialog *zd, cchar *event) int batch_convert_dialog_event(zdialog *zd, ch *event)
{ {
using namespace batch_convert; using namespace batch_convert;
char *pp, *ploc, badplug[20]; ch *pp, *ploc, badplug[20];
char countmess[80]; ch countmess[80];
int ii, cc, yn, err; int ii, cc, yn, err;
if (strmatch(event,"files")) // select images to convert if (strmatch(event,"files")) // select images to convert
{ {
zdialog_show(zd,0); // hide parent dialog zdialog_show(zd,0); // hide parent dialog
gallery_select(); // get list of files to convert gallery_select(); // get list of files to convert
zdialog_show(zd,1); zdialog_show(zd,1);
snprintf(countmess,80,"%d image files selected",GScount); // update dialog snprintf(countmess,80,"%d image files selected",GScount); // update dialog
zdialog_stuff(zd,"fcount",countmess); zdialog_stuff(zd,"fcount",countmess);
skipping to change at line 671 skipping to change at line 670
Convert to .ext N-bits/color CX CXa Convert to .ext N-bits/color CX CXa
Downsize within NNxNN DZ Downsize within NNxNN DZ
Upsize within NNxNN UZ UZa Upsize within NNxNN UZ UZa
Output to /.../... OP Output to /.../... OP
Copy Metadata Upright CM Copy Metadata Upright CM
*** Delete Originals *** DO *** Delete Originals *** DO
*** Replace Originals *** RO *** Replace Originals *** RO
PROCEED? PR PROCEED? PR
**/ **/
char messCF[60], messRN[100], messRT[230], messCX[60], messCXa[60], ch messCF[60], messRN[100], messRT[230], messCX[60], messCXa[60],
messDZ[60], messDZa[60], messOP[550], messCM[80], messDO[60], messDZ[60], messDZa[60], messOP[550], messCM[80], messDO[60],
messRO[60], messPR[40]; messRO[60], messPR[40];
char warnmess[1000]; ch warnmess[1000];
*messCF = *messRN = *messRT = *messCX = *messCXa = *messDZ = *messDZa *messCF = *messRN = *messRT = *messCX = *messCXa = *messDZ = *messDZa
= *messOP = *messCM = *messDO = *messRO = *messPR = 0; = *messOP = *messCM = *messDO = *messRO = *messPR = 0;
snprintf(messCF,60,"Convert %d image files",GScount); snprintf(messCF,60,"Convert %d image files",GScount);
if (Fnewtext) snprintf(messRT,230,"\n Replace text: %s → %s",text1,text2); // 22.50 if (Fnewtext) snprintf(messRT,230,"\n Replace text: %s → %s",text1,text2); // 22.50
if (*newname) snprintf(messRN,100,"\n %s %s","Rename to",newname); if (*newname) snprintf(messRN,100,"\n %s %s","Rename to",newname);
if (! Fsametype) snprintf(messCX,60,"\n %s %s","Convert to",newext); if (! Fsametype) snprintf(messCX,60,"\n %s %s","Convert to",newext);
if (! Fsamebpc) snprintf(messCXa,60,"\n %d-bits/color",newbpc); if (! Fsamebpc) snprintf(messCXa,60,"\n %d-bits/color",newbpc);
if (Fdownsize) snprintf(messDZ,60,"\n %s %dx%d","Downsize within",maxww,maxh h); if (Fdownsize) snprintf(messDZ,60,"\n %s %dx%d","Downsize within",maxww,maxh h);
skipping to change at line 711 skipping to change at line 710
zd->zstat = 1; // [proceed] zd->zstat = 1; // [proceed]
return 1; return 1;
} }
/******************************************************************************* */ /******************************************************************************* */
// Move selected files to a new location (Fotoxx indexed) // Move selected files to a new location (Fotoxx indexed)
namespace batch_copy_move_names namespace batch_copy_move_names
{ {
char newloc[500]; // destination folder ch newloc[500]; // destination folder
int Fdelete; // delete originals int Fdelete; // delete originals
} }
// menu function // menu function
void m_batch_copy_move(GtkWidget *, cchar *) // 22.15 void m_batch_copy_move(GtkWidget *, ch *) // 22.15
{ {
using namespace batch_copy_move_names; using namespace batch_copy_move_names;
int batch_copy_move_dialog_event(zdialog *zd, cchar *event); int batch_copy_move_dialog_event(zdialog *zd, ch *event);
zdialog *zd, *zd2; zdialog *zd, *zdpop;
int ii, cc, err; int ii, cc, err;
int zstat; int zstat;
char *pp, text[100]; ch *pp, text[100];
char *infile, *outfile; ch *infile, *outfile;
char **oldfiles, **newfiles; ch **oldfiles, **newfiles;
int Noldnew; int Noldnew;
F1_help_topic = "batch copy/move"; F1_help_topic = "batch copy/move";
Plog(1,"m_batch_copy_move \n"); Plog(1,"m_batch_copy_move \n");
if (Fblock("batch_copy_move","block edits")) return; // check pending, block if (Fblock("batch_copy_move","block edits")) return; // check pending, block
/*** /***
___________________________________________________________ ___________________________________________________________
skipping to change at line 786 skipping to change at line 785
zdialog_restore_inputs(zd); // preload prior user inputs zdialog_restore_inputs(zd); // preload prior user inputs
zdialog_run(zd,batch_copy_move_dialog_event,"parent"); // run dialog zdialog_run(zd,batch_copy_move_dialog_event,"parent"); // run dialog
zstat = zdialog_wait(zd); // wait for completion zstat = zdialog_wait(zd); // wait for completion
zdialog_free(zd); zdialog_free(zd);
if (zstat != 1) goto cleanup; // canceled if (zstat != 1) goto cleanup; // canceled
if (! GScount) goto cleanup; // no files selected if (! GScount) goto cleanup; // no files selected
free_resources(); // no curr. file free_resources(); // no curr. file
if (Fdelete) { if (Fdelete) {
cc = GScount * sizeof(char *); cc = GScount * sizeof(ch *);
// input files are to be deleted: // input files are to be deleted:
oldfiles = (char **) zmalloc(cc,"batch copy/move"); oldfiles = (ch **) zmalloc(cc,"batch copy/move");
// reserve space to hold list of // reserve space to hold list of
newfiles = (char **) zmalloc(cc,"batch copy/move"); newfiles = (ch **) zmalloc(cc,"batch copy/move");
// old/new filespecs to update albums // old/new filespecs to update albums
} }
cc = strlen(newloc); // output location cc = strlen(newloc); // output location
if (newloc[cc-1] == '/') newloc[cc-1] = 0; // remove trailing '/' if (newloc[cc-1] == '/') newloc[cc-1] = 0; // remove trailing '/'
zd2 = popup_report_open("Processing files",Mwin,600,300,0,0,"OK",0); // log report 22.15 zdpop = popup_report_open("Processing files",Mwin,600,300,0,0,"OK",0); // log report 22.15
for (ii = 0; ii < GScount; ii++) // loop selected files for (ii = 0; ii < GScount; ii++) // loop selected files
{ {
zmainloop(); // keep GTK alive zmainloop(); // keep GTK alive
if (zd2->zstat) break; // function canceled if (! zdialog_valid(zdpop)) break; // report canceled 23.1
infile = GSfiles[ii]; // input file infile = GSfiles[ii]; // input file
popup_report_write2(zd2,0,"\n"); popup_report_write2(zdpop,0,"\n");
popup_report_write2(zd2,0,"%s \n",infile); popup_report_write2(zdpop,0,"%s \n",infile);
// log each input file // log each input file
if (image_file_type(infile) != IMAGE) { if (image_file_type(infile) != IMAGE) {
popup_report_write2(zd2,0,"*** invalid file \n"); popup_report_write2(zdpop,0,"*** invalid file \n");
continue; continue;
} }
pp = strrchr(infile,'/'); // /filename.ext pp = strrchr(infile,'/'); // /filename.ext
cc = strlen(newloc) + strlen(pp) + 2; cc = strlen(newloc) + strlen(pp) + 2;
outfile = (char *) zmalloc(cc,"batch copy/move"); outfile = (ch *) zmalloc(cc,"batch copy/move");
strcpy(outfile,newloc); // /newloc/.../filename.ext strcpy(outfile,newloc); // /newloc/.../filename.ext
strcat(outfile,pp); strcat(outfile,pp);
popup_report_write2(zd2,0,"%s \n",outfile); // log each output file popup_report_write2(zdpop,0,"%s \n",outfile); // log each output file
if (regfile(outfile)) { // check if file exists in new location if (regfile(outfile)) { // check if file exists in new location
popup_report_write2(zd2,1,"%s \n","output file exists"); popup_report_write2(zdpop,1,"%s \n","output file exists");
zfree(outfile); zfree(outfile);
continue; continue;
} }
err = cp_copy(infile,outfile); // copy infile to outfile err = cp_copy(infile,outfile); // copy infile to outfile
if (err) { if (err) {
popup_report_write2(zd2,1,"%s \n",strerror(err)); // error, do nothing popup_report_write2(zdpop,1,"%s \n",strerror(err)); // error, do nothing
zfree(outfile); zfree(outfile);
continue; continue;
} }
load_filemeta(outfile); // update image index for output file load_filemeta(outfile); // update image index for output file
update_image_index(outfile); update_image_index(outfile);
if (Fdelete) // delete input file if (Fdelete) // delete input file
{ {
err = f_remove(infile,"delete"); // file/index/thumb/gallery err = f_remove(infile,"delete"); // file/index/thumb/gallery
oldfiles[Noldnew] = zstrdup(infile,"batch copy/move"); // mark for updating albums oldfiles[Noldnew] = zstrdup(infile,"batch copy/move"); // mark for updating albums
newfiles[Noldnew] = zstrdup(outfile,"batch copy/move"); newfiles[Noldnew] = zstrdup(outfile,"batch copy/move");
Noldnew++; Noldnew++;
} }
zfree(outfile); zfree(outfile);
} }
if (! zdialog_valid(zdpop)) {
// 23.1
Plog(0,"*** report cancelled \n");
goto cleanup;
}
if (Noldnew) { // update albums for renamed/moved files if (Noldnew) { // update albums for renamed/moved files
popup_report_write2(zd2,0,"%s \n","updating albums ..."); popup_report_write2(zdpop,0,"%s \n","updating albums ...");
album_purge_replace("ALL",Noldnew,oldfiles,newfiles); album_purge_replace("ALL",Noldnew,oldfiles,newfiles);
} }
if (zd2->zstat) popup_report_write2(zdpop,0,"\n *** %s \n","COMPLETED");
// popup report canceled popup_report_bottom(zdpop);
popup_report_write2(zd2,0,"\n *** %s \n","CANCELED");
else popup_report_write2(zd2,0,"\n *** %s \n","COMPLETED");
popup_report_bottom(zd2);
cleanup: cleanup:
if (Noldnew) { if (Noldnew) {
for (ii = 0; ii < Noldnew; ii++) { for (ii = 0; ii < Noldnew; ii++) {
zfree(oldfiles[ii]); zfree(oldfiles[ii]);
zfree(newfiles[ii]); zfree(newfiles[ii]);
} }
if (oldfiles) zfree(oldfiles); if (oldfiles) zfree(oldfiles);
if (newfiles) zfree(newfiles); if (newfiles) zfree(newfiles);
skipping to change at line 880 skipping to change at line 882
gallery(navi::galleryname,"init",0); // refresh file list gallery(navi::galleryname,"init",0); // refresh file list
gallery(0,"sort",-2); // recall sort and position gallery(0,"sort",-2); // recall sort and position
gallery(0,"paint",-1); // repaint from same position gallery(0,"paint",-1); // repaint from same position
Fblock("batch_copy_move",0); Fblock("batch_copy_move",0);
return; return;
} }
// dialog event and completion callback function // dialog event and completion callback function
int batch_copy_move_dialog_event(zdialog *zd, cchar *event) int batch_copy_move_dialog_event(zdialog *zd, ch *event)
{ {
using namespace batch_copy_move_names; using namespace batch_copy_move_names;
char countmess[80]; ch countmess[80];
char *ploc; ch *ploc;
int cc, yn, err; int cc, yn, err;
if (strmatch(event,"files")) // select images to convert if (strmatch(event,"files")) // select images to convert
{ {
zdialog_show(zd,0); // hide parent dialog zdialog_show(zd,0); // hide parent dialog
gallery_select(); // get list of files to convert gallery_select(); // get list of files to convert
zdialog_show(zd,1); zdialog_show(zd,1);
snprintf(countmess,80,"%d image files selected",GScount); // update dialog snprintf(countmess,80,"%d image files selected",GScount); // update dialog
zdialog_stuff(zd,"fcount",countmess); zdialog_stuff(zd,"fcount",countmess);
skipping to change at line 931 skipping to change at line 933
err = check_create_dir(newloc); // create if needed err = check_create_dir(newloc); // create if needed
if (err) return 1; if (err) return 1;
/** /**
Move NN image files 0 Move NN image files 0
New Location: /.../... 1 New Location: /.../... 1
*** Delete Originals *** 2 *** Delete Originals *** 2
PROCEED? 3 PROCEED? 3
**/ **/
char mess0[60], mess1[600], mess2[60], mess3[40]; ch mess0[60], mess1[600], mess2[60], mess3[40];
char warnmess[800]; ch warnmess[800];
*mess0 = *mess1 = *mess2 = *mess3 = 0; *mess0 = *mess1 = *mess2 = *mess3 = 0;
snprintf(mess0,60,"Move %d image files",GScount); snprintf(mess0,60,"Move %d image files",GScount);
snprintf(mess1,600,"\n New Location: %s",newloc); snprintf(mess1,600,"\n New Location: %s",newloc);
if (Fdelete) snprintf(mess2,60,"\n *** Delete Originals ***"); if (Fdelete) snprintf(mess2,60,"\n *** Delete Originals ***");
snprintf(mess3,40,"\n PROCEED?"); snprintf(mess3,40,"\n PROCEED?");
snprintf(warnmess,800,"%s %s %s %s",mess0,mess1,mess2,mess3); snprintf(warnmess,800,"%s %s %s %s",mess0,mess1,mess2,mess3);
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;
} }
/******************************************************************************* */ /******************************************************************************* */
// Batch upright image files. // Batch upright image files.
// Look for files rotated 90˚ (according to EXIF) and upright them. // Look for files rotated 90˚ (according to metadata) and upright them.
char **bup_filelist = 0; ch **bup_filelist = 0;
int bup_filecount = 0; int bup_filecount = 0;
int bup_allfiles; int bup_allfiles;
void m_batch_upright(GtkWidget *, cchar *) void m_batch_upright(GtkWidget *, ch *)
{ {
int batch_upright_dialog_event(zdialog *zd, cchar *event); int batch_upright_dialog_event(zdialog *zd, ch *event);
zdialog *zd, *zd2; zdialog *zd, *zdpop;
int zstat; int zstat;
char *infile, *tempfile; ch *infile, *tempfile;
char *pp1, *pp2, *ppv[1], text[100]; ch *pp1, *pp2, *ppv[1], text[100];
int ii, cc, err, bpc; int ii, cc, err, bpc;
PXM *pxmin, *pxmout; PXM *pxmin, *pxmout;
cchar *exifkey[1] = { exif_orientation_key }; ch *metakey[1] = { meta_orientation_key };
cchar *exifdata[1]; ch *metadata[1];
char orient; ch orient;
F1_help_topic = "batch upright"; F1_help_topic = "batch upright";
Plog(1,"m_batch_upright \n"); Plog(1,"m_batch_upright \n");
if (Findexvalid == 0) { if (Findexvalid == 0) {
zmessageACK(Mwin,"image index disabled"); // no image index zmessageACK(Mwin,"image index disabled"); // no image index
return; return;
} }
skipping to change at line 1018 skipping to change at line 1020
bup_filecount = 0; bup_filecount = 0;
zdialog_run(zd,batch_upright_dialog_event,"parent"); // run dialog zdialog_run(zd,batch_upright_dialog_event,"parent"); // run dialog
zstat = zdialog_wait(zd); // wait for completion zstat = zdialog_wait(zd); // wait for completion
zdialog_free(zd); zdialog_free(zd);
if (zstat != 1) goto cleanup; // canceled if (zstat != 1) goto cleanup; // canceled
if (! bup_allfiles && ! bup_filecount) goto cleanup; // nothing selected if (! bup_allfiles && ! bup_filecount) goto cleanup; // nothing selected
free_resources(); // no curr. file free_resources(); // no curr. file
zd2 = popup_report_open("Processing files",Mwin,500,200,0,0,"OK",0); // log report 22.15 zdpop = popup_report_open("Processing files",Mwin,500,200,0,0,"OK",0); // log report 22.15
if (bup_allfiles) // "survey all files" selected if (bup_allfiles) // "survey all files" selected
{ {
cc = Nxxrec * sizeof(char *); cc = Nxxrec * sizeof(ch *);
bup_filelist = (char **) zmalloc(cc,"batch upright"); bup_filelist = (ch **) zmalloc(cc,"batch upright");
for (ii = 0; ii < Nxxrec; ii++) for (ii = 0; ii < Nxxrec; ii++)
bup_filelist[ii] = zstrdup(xxrec_tab[ii]->file,"batch upright"); bup_filelist[ii] = zstrdup(xxrec_tab[ii]->file,"batch upright");
bup_filecount = Nxxrec; bup_filecount = Nxxrec;
} }
for (ii = 0; ii < bup_filecount; ii++) // loop selected files for (ii = 0; ii < bup_filecount; ii++) // loop selected files
{ {
zmainloop(); // keep GTK alive zmainloop(); // keep GTK alive
if (zd2->zstat) break; // function canceled if (! zdialog_valid(zdpop)) break; // report canceled 23.1
infile = bup_filelist[ii]; // input file infile = bup_filelist[ii]; // input file
popup_report_write2(zd2,0,"%s \n",infile); // log each output file popup_report_write2(zdpop,0,"%s \n",infile); // log each output file
if (image_file_type(infile) != IMAGE) { if (image_file_type(infile) != IMAGE) {
popup_report_write2(zd2,0,"*** invalid file \n"); popup_report_write2(zdpop,0,"*** invalid file \n");
continue; continue;
} }
exif_get(infile,exifkey,ppv,1); // get EXIF: Orientation meta_get1(infile,(ch **) metakey,ppv,1); // get metadata Orientation
if (! ppv[0]) continue; if (! ppv[0]) continue;
orient = *ppv[0]; orient = *ppv[0];
zfree(ppv[0]); zfree(ppv[0]);
if (orient == '1') continue; // not rotated if (orient == '1') continue; // not rotated
pxmin = PXM_load(infile,0); // read input file pxmin = PXM_load(infile,0); // read input file
if (! pxmin) { if (! pxmin) {
popup_report_write2(zd2,1,"%s \n","file cannot be read"); popup_report_write2(zdpop,1,"%s \n","file cannot be read");
continue; continue;
} }
pxmout = 0; pxmout = 0;
if (orient == '6') if (orient == '6')
pxmout = PXM_rotate(pxmin,+90); // rotate clockwise 90 deg. pxmout = PXM_rotate(pxmin,+90); // rotate clockwise 90 deg.
if (orient == '8') if (orient == '8')
pxmout = PXM_rotate(pxmin,-90); // counterclockwise pxmout = PXM_rotate(pxmin,-90); // counterclockwise
if (orient == '3') if (orient == '3')
pxmout = PXM_rotate(pxmin,180); // 180 deg. pxmout = PXM_rotate(pxmin,180); // 180 deg.
PXM_free(pxmin); PXM_free(pxmin);
if (! pxmout) continue; // not rotated if (! pxmout) continue; // not rotated
tempfile = zstrdup(infile,"batch upright",12); // temp file needed for EXIF/IPTC copy tempfile = zstrdup(infile,"batch upright",12); // temp file needed for meta copy
pp1 = strrchr(infile,'.'); pp1 = strrchr(infile,'.');
pp2 = strrchr(tempfile,'.'); pp2 = strrchr(tempfile,'.');
strcpy(pp2,"-temp"); strcpy(pp2,"-temp");
strcpy(pp2+5,pp1); strcpy(pp2+5,pp1);
bpc = f_load_bpc; // input file bits/color bpc = f_load_bpc; // input file bits/color
if (strmatch(f_load_type,"tif")) if (strmatch(f_load_type,"tif"))
err = PXM_TIFF_save(pxmout,tempfile,bpc); err = PXM_TIFF_save(pxmout,tempfile,bpc);
else if (strmatch(f_load_type,"png")) else if (strmatch(f_load_type,"png"))
err = PXM_PNG_save(pxmout,tempfile,bpc); err = PXM_PNG_save(pxmout,tempfile,bpc);
else err = PXM_JPG_save(pxmout,tempfile,jpeg_def_quality); else err = PXM_JPG_save(pxmout,tempfile,jpeg_def_quality);
PXM_free(pxmout); PXM_free(pxmout);
if (err) { if (err) {
popup_report_write2(zd2,1," upright failed \n"); popup_report_write2(zdpop,1," upright failed \n");
zfree(tempfile); zfree(tempfile);
continue; continue;
} }
exifdata[0] = ""; metadata[0] = 0;
// remove exif:orientation // remove metadata orientation
err = exif_copy(infile,tempfile,exifkey,exifdata,1); err = meta_copy(infile,tempfile,(ch **) metakey,metadata,1);
// (set = 1 does not work) // (set = 1 does not work)
if (err) popup_report_write2(zd2,1,"exif update error \n"); if (err) popup_report_write2(zdpop,1,"metadata update error \n");
// 23.0 // 23.0
err = cp_copy(tempfile,infile); // copy temp file to input file err = cp_copy(tempfile,infile); // copy temp file to input file
if (err) popup_report_write2(zd2,1,"%s \n",strerror(err)); if (err) popup_report_write2(zdpop,1,"%s \n",strerror(err));
remove(tempfile); // remove tempfile remove(tempfile); // remove tempfile
zfree(tempfile); zfree(tempfile);
if (! err) { if (! err) {
load_filemeta(infile); // update image index load_filemeta(infile); // update image index
update_image_index(infile); update_image_index(infile);
popup_report_write2(zd2,0," uprighted \n"); popup_report_write2(zdpop,0," uprighted \n");
} }
gallery(0,"paint",-1); // repaint gallery gallery(0,"paint",-1); // repaint gallery
} }
if (zd2->zstat) if (! zdialog_valid(zdpop)) {
// popup report canceled // 23.1
popup_report_write2(zd2,0,"\n *** function canceled \n"); Plog(0,"*** report cancelled \n");
else popup_report_write2(zd2,0,"\n *** COMPLETED \n"); goto cleanup;
popup_report_bottom(zd2); }
popup_report_write2(zdpop,0,"\n *** COMPLETED \n");
popup_report_bottom(zdpop);
cleanup: cleanup:
if (bup_filecount) { // free memory if (bup_filecount) { // free memory
for (ii = 0; ii < bup_filecount; ii++) for (ii = 0; ii < bup_filecount; ii++)
zfree(bup_filelist[ii]); zfree(bup_filelist[ii]);
zfree(bup_filelist); zfree(bup_filelist);
bup_filelist = 0; bup_filelist = 0;
bup_filecount = 0; bup_filecount = 0;
} }
Fblock("batch_upright",0); Fblock("batch_upright",0);
return; return;
} }
// dialog event and completion callback function // dialog event and completion callback function
int batch_upright_dialog_event(zdialog *zd, cchar *event) int batch_upright_dialog_event(zdialog *zd, ch *event)
{ {
char countmess[80]; ch countmess[80];
int ii; int ii;
if (strmatch(event,"files")) // select images to convert if (strmatch(event,"files")) // select images to convert
{ {
if (bup_filecount) { if (bup_filecount) {
for (ii = 0; ii < bup_filecount; ii++) // free prior list for (ii = 0; ii < bup_filecount; ii++) // free prior list
zfree(bup_filelist[ii]); zfree(bup_filelist[ii]);
zfree(bup_filelist); zfree(bup_filelist);
bup_filelist = 0; bup_filelist = 0;
bup_filecount = 0; bup_filecount = 0;
} }
skipping to change at line 1154 skipping to change at line 1159
gallery_select(); // get new list gallery_select(); // get new list
zdialog_show(zd,1); zdialog_show(zd,1);
snprintf(countmess,80,"%d image files selected",GScount); // update dialog snprintf(countmess,80,"%d image files selected",GScount); // update dialog
zdialog_stuff(zd,"fcount",countmess); zdialog_stuff(zd,"fcount",countmess);
zdialog_stuff(zd,"allfiles",0); zdialog_stuff(zd,"allfiles",0);
if (! GScount) return 1; if (! GScount) return 1;
bup_filelist = bup_filelist =
(char **) zmalloc(GScount * sizeof(char *),"batch upright"); // copy selected files (ch **) zmalloc(GScount * sizeof(ch *),"batch upright"); // copy selected files
for (ii = 0; ii < GScount; ii++) for (ii = 0; ii < GScount; ii++)
bup_filelist[ii] = GSfiles[ii]; bup_filelist[ii] = GSfiles[ii];
bup_filecount = GScount; bup_filecount = GScount;
GScount = 0; GScount = 0;
} }
if (zd->zstat != 1) return 1; // wait for [proceed] if (zd->zstat != 1) return 1; // wait for [proceed]
zdialog_fetch(zd,"allfiles",bup_allfiles); // get "survey all" option zdialog_fetch(zd,"allfiles",bup_allfiles); // get "survey all" option
skipping to change at line 1184 skipping to change at line 1189
return 1; return 1;
} }
/******************************************************************************* */ /******************************************************************************* */
// Batch delete or trash image files. // Batch delete or trash image files.
int bdt_option; // 1/2 = delete/trash int bdt_option; // 1/2 = delete/trash
void m_batch_deltrash(GtkWidget *, cchar *) void m_batch_deltrash(GtkWidget *, ch *)
{ {
int batch_deltrash_dialog_event(zdialog *zd, cchar *event); int batch_deltrash_dialog_event(zdialog *zd, ch *event);
zdialog *zd, *zd2; zdialog *zd, *zdpop;
int zstat, ii, nn, err; int zstat, ii, nn, err;
char *file, text[100]; ch *file, text[100];
char **delfiles = 0; ch **delfiles = 0;
int cc, Ndel = 0; int cc, Ndel = 0;
F1_help_topic = "batch delete/trash"; F1_help_topic = "batch delete/trash";
Plog(1,"m_batch_deltrash \n"); Plog(1,"m_batch_deltrash \n");
if (Fblock("batch_deltrash","block edits")) return; // check pending, block if (Fblock("batch_deltrash","block edits")) return; // check pending, block
/*** /***
___________________________________ ___________________________________
skipping to change at line 1243 skipping to change at line 1248
zdialog_fetch(zd,"delete",bdt_option); // get delete/trash option zdialog_fetch(zd,"delete",bdt_option); // get delete/trash option
if (! bdt_option) bdt_option = 2; if (! bdt_option) bdt_option = 2;
zdialog_free(zd); zdialog_free(zd);
if (zstat != 1) goto finish; // canceled if (zstat != 1) goto finish; // canceled
if (! GScount) goto finish; if (! GScount) goto finish;
free_resources(); // no curr. file free_resources(); // no curr. file
cc = GScount * sizeof(char *); cc = GScount * sizeof(ch *);
// files to purge from albums // files to purge from albums
delfiles = (char **) zmalloc(cc,"batch deltrash"); delfiles = (ch **) zmalloc(cc,"batch deltrash");
Ndel = 0; Ndel = 0;
zd2 = popup_report_open("Processing files",Mwin,500,200,0,0,"OK",0); // log report 22.15 zdpop = popup_report_open("Processing files",Mwin,500,200,0,0,"OK",0); // log report 22.15
for (ii = 0; ii < GScount; ii++) // loop selected files for (ii = 0; ii < GScount; ii++) // loop selected files
{ {
zmainloop(); // keep GTK alive zmainloop(); // keep GTK alive
if (zd2->zstat) break; // function canceled if (! zdialog_valid(zdpop)) break; // report canceled 23.1
file = GSfiles[ii]; // log each file file = GSfiles[ii]; // log each file
popup_report_write2(zd2,0,"%s \n",file); popup_report_write2(zdpop,0,"%s \n",file);
if (! regfile(file)) { // file exists? if (! regfile(file)) { // file exists?
popup_report_write2(zd2,1,"file not found \n"); popup_report_write2(zdpop,1,"file not found \n");
continue; continue;
} }
err = 0; err = 0;
if (bdt_option == 1) // delete file if (bdt_option == 1) // delete file
err = f_remove(file,"delete"); // file/index/thumb/gallery err = f_remove(file,"delete"); // file/index/thumb/gallery
if (bdt_option == 2) // move file to trash if (bdt_option == 2) // move file to trash
err = f_remove(file,"trash"); err = f_remove(file,"trash");
if (err) { if (err) {
popup_report_write2(zd2,1,"move to trash failed \n"); // gnome trash failed popup_report_write2(zdpop,1,"move to trash failed \n"); // gnome trash failed
nn = zdialog_choose(Mwin,"parent","continue?","Yes","Quit",0); nn = zdialog_choose(Mwin,"parent","continue?","Yes","Quit",0);
if (nn == 2) { // quit if (nn == 2) { // quit
zd2->zstat = 1; zdpop->zstat = 1;
break; break;
} }
} }
delfiles[Ndel] = zstrdup(file,"batch deltrash"); // add to deleted files list delfiles[Ndel] = zstrdup(file,"batch deltrash"); // add to deleted files list
Ndel++; Ndel++;
} }
if (zd2->zstat) if (! zdialog_valid(zdpop)) {
// popup report canceled // 23.1
popup_report_write2(zd2,0,"\n *** %s \n","function canceled"); Plog(0,"*** report cancelled \n");
else popup_report_write2(zd2,0,"\n *** %s \n","COMPLETED"); goto finish;
popup_report_bottom(zd2); }
zd2->zstat = 0;
// keep dialog active
if (Ndel) { if (Ndel) {
popup_report_write2(zd2,0,"Purging deleted files from albums \n"); // purge deleted files from albums popup_report_write2(zdpop,0,"Purging deleted files from albums \n"); // purge deleted files from albums
album_purge_replace("ALL",Ndel,delfiles,0); album_purge_replace("ALL",Ndel,delfiles,0);
} }
popup_report_write2(zdpop,0,"\n *** %s \n","COMPLETED");
popup_report_bottom(zdpop);
finish:
for (ii = 0; ii < Ndel; ii++) // free memory for (ii = 0; ii < Ndel; ii++) // free memory
zfree(delfiles[ii]); zfree(delfiles[ii]);
if (delfiles) zfree(delfiles); if (delfiles) zfree(delfiles);
popup_report_write2(zd2,0,"\n *** %s \n","COMPLETED");
popup_report_bottom(zd2);
finish:
gallery(navi::galleryname,"init",0); // refresh file list gallery(navi::galleryname,"init",0); // refresh file list
gallery(0,"sort",-2); // recall sort and position gallery(0,"sort",-2); // recall sort and position
gallery(0,"paint",-1); // repaint from same position gallery(0,"paint",-1); // repaint from same position
Fblock("batch_deltrash",0); Fblock("batch_deltrash",0);
return; return;
} }
// dialog event and completion callback function // dialog event and completion callback function
int batch_deltrash_dialog_event(zdialog *zd, cchar *event) int batch_deltrash_dialog_event(zdialog *zd, ch *event)
{ {
char countmess[80]; ch countmess[80];
int ii; int ii;
if (strmatch(event,"files")) // select images to convert if (strmatch(event,"files")) // select images to convert
{ {
zdialog_show(zd,0); // hide parent dialog zdialog_show(zd,0); // hide parent dialog
gallery_select(); gallery_select();
zdialog_show(zd,1); zdialog_show(zd,1);
snprintf(countmess,80,"%d image files selected",GScount); // update dialog snprintf(countmess,80,"%d image files selected",GScount); // update dialog
zdialog_stuff(zd,"fcount",countmess); zdialog_stuff(zd,"fcount",countmess);
skipping to change at line 1354 skipping to change at line 1358
return 1; return 1;
} }
/******************************************************************************* */ /******************************************************************************* */
// convert multiple RAW files to tiff, jpeg, or png // convert multiple RAW files to tiff, jpeg, or png
namespace batch_raw namespace batch_raw
{ {
char location[400], biasfile[400]; ch location[400], biasfile[400];
cchar *filetype = 0; ch *filetype = 0;
int bpc, jpeg_quality; int bpc, jpeg_quality;
float resize; float resize;
int amount, thresh; int amount, thresh;
}; };
void m_batch_RAW(GtkWidget *, cchar *menu) void m_batch_RAW(GtkWidget *, ch *menu)
{ {
using namespace batch_raw; using namespace batch_raw;
int batch_raw_dialog_event(zdialog *zd, cchar *event); int batch_raw_dialog_event(zdialog *zd, ch *event);
zdialog *zd, *zd2; zdialog *zd, *zdpop;
cchar *title = "Batch Convert RAW Files"; ch *title = "Batch Convert RAW Files";
char *rawfile, *tempfile, *outfile, *pp; ch *rawfile, *tempfile, *outfile, *pp;
char text[100]; ch text[100];
int zstat, ii, err; int zstat, ii, err;
FTYPE ftype; FTYPE ftype;
int cc, ww2, hh2; int cc, ww2, hh2;
PXM *pxm1, *pxm2; PXM *pxm1, *pxm2;
F1_help_topic = "batch raw"; F1_help_topic = "batch raw";
Plog(1,"m_batch_RAW \n"); Plog(1,"m_batch_RAW \n");
if (Fblock("batch_RAW","block edits")) return; // check pending, block if (Fblock("batch_RAW","block edits")) return; // check pending, block
skipping to change at line 1456 skipping to change at line 1460
zdialog_run(zd,batch_raw_dialog_event,"parent"); // run dialog zdialog_run(zd,batch_raw_dialog_event,"parent"); // run dialog
zstat = zdialog_wait(zd); // wait for completion zstat = zdialog_wait(zd); // wait for completion
zdialog_free(zd); zdialog_free(zd);
if (zstat != 1) goto cleanup; if (zstat != 1) goto cleanup;
if (! GScount) goto cleanup; if (! GScount) goto cleanup;
m_viewmode(0,"F"); m_viewmode(0,"F");
zd2 = popup_report_open("Converting RAW files",Mwin,500,200,0,0,"OK",0); // log report 22.15 zdpop = popup_report_open("Converting RAW files",Mwin,500,200,0,0,"OK",0); // log report 22.15
for (ii = 0; ii < GScount; ii++) // loop all RAW files for (ii = 0; ii < GScount; ii++) // loop all RAW files
{ {
zmainloop(); zmainloop();
if (zd2->zstat) break; // function canceled if (! zdialog_valid(zdpop)) break; // report canceled 23.1
rawfile = GSfiles[ii]; // filename.raw rawfile = GSfiles[ii]; // filename.raw
popup_report_write2(zd2,0,"%s \n",rawfile); // write to log window popup_report_write2(zdpop,0,"%s \n",rawfile); // write to log window
ftype = image_file_type(rawfile); ftype = image_file_type(rawfile);
if (ftype != RAW) { if (ftype != RAW) {
popup_report_write2(zd2,1," unknown RAW file type \n"); popup_report_write2(zdpop,1," unknown RAW file type \n");
continue; continue;
} }
pxm1 = RAW_PXM_load(rawfile,Fautobright,Fmatchthumb); pxm1 = RAW_PXM_load(rawfile,Fautobright,Fmatchthumb);
if (! pxm1) continue; if (! pxm1) continue;
zmainloop(); zmainloop();
if (resize < 1.0) // resize down if wanted if (resize < 1.0) // resize down if wanted
{ {
ww2 = resize * pxm1->ww; ww2 = resize * pxm1->ww;
hh2 = resize * pxm1->hh; hh2 = resize * pxm1->hh;
pxm2 = PXM_rescale(pxm1,ww2,hh2); pxm2 = PXM_rescale(pxm1,ww2,hh2);
PXM_free(pxm1); PXM_free(pxm1);
pxm1 = pxm2; pxm1 = pxm2;
if (! pxm1) { if (! pxm1) {
popup_report_write2(zd2,1," resize failed \n"); popup_report_write2(zdpop,1," resize failed \n");
continue; continue;
} }
} }
outfile = zstrdup(rawfile,"batch raw",5); // output file name = RAW file name outfile = zstrdup(rawfile,"batch raw",5); // output file name = RAW file name
pp = strrchr(outfile,'.'); // rename: *.tif *.jpg *.png pp = strrchr(outfile,'.'); // rename: *.tif *.jpg *.png
if (pp) strcpy(pp,filetype); if (pp) strcpy(pp,filetype);
err = PXM_save(pxm1,outfile,bpc,jpeg_quality,1); err = PXM_save(pxm1,outfile,bpc,jpeg_quality,1);
PXM_free(pxm1); PXM_free(pxm1);
if (err) { if (err) {
popup_report_write2(zd2,1," file type conversion failed \n"); popup_report_write2(zdpop,1," file type conversion failed \n");
zfree(outfile); zfree(outfile);
continue; continue;
} }
err = exif_copy(rawfile,outfile,0,0,0); err = meta_copy(rawfile,outfile,0,0,0);
// copy metadata from RAW file // copy metadata from RAW file
if (err) popup_report_write2(zd2,1," exif update error \n"); if (err) popup_report_write2(zdpop,1," metadata update error \n");
// 23.0 // 23.0
if (*location && ! samefolder(location,outfile)) { if (*location && ! samefolder(location,outfile)) {
tempfile = zstrdup(outfile,"batch raw"); // copy to new location tempfile = zstrdup(outfile,"batch raw"); // copy to new location
zfree(outfile); zfree(outfile);
pp = strrchr(tempfile,'/'); // /raw-location/filename.ext pp = strrchr(tempfile,'/'); // /raw-location/filename.ext
cc = strlen(pp); // | cc = strlen(pp); // |
outfile = zstrdup(location,"batch raw",cc+1); // pp outfile = zstrdup(location,"batch raw",cc+1); // pp
strcat(outfile,pp); // /new-location/filename.ext strcat(outfile,pp); // /new-location/filename.ext
err = cp_copy(tempfile,outfile); // copy to new location err = cp_copy(tempfile,outfile); // copy to new location
if (err) popup_report_write2(zd2,1," %s \n",strerror(err)); if (err) popup_report_write2(zdpop,1," %s \n",strerror(err));
remove(tempfile); // remove tempfile remove(tempfile); // remove tempfile
zfree(tempfile); zfree(tempfile);
} }
f_open(outfile,0,0,0); // open converted file f_open(outfile,0,0,0); // open converted file
update_image_index(outfile); update_image_index(outfile);
popup_report_write2(zd2,0,"%s \n",outfile); // write output file to log window popup_report_write2(zdpop,0,"%s \n",outfile); // write output file to log window
zfree(outfile); zfree(outfile);
} }
if (zd2->zstat) if (! zdialog_valid(zdpop)) {
// popup report canceled // 23.1
popup_report_write2(zd2,0,"\n *** function canceled \n"); Plog(0,"*** report cancelled \n");
else popup_report_write2(zd2,0,"\n *** COMPLETED \n"); goto cleanup;
popup_report_bottom(zd2); }
popup_report_write2(zdpop,0,"\n *** COMPLETED \n");
popup_report_bottom(zdpop);
cleanup: // clean up and return cleanup: // clean up and return
gallery(navi::galleryname,"init",0); // refresh file list gallery(navi::galleryname,"init",0); // refresh file list
gallery(0,"sort",-2); // recall sort and position gallery(0,"sort",-2); // recall sort and position
gallery(0,"paint",-1); // repaint from same position gallery(0,"paint",-1); // repaint from same position
Fblock("batch_RAW",0); Fblock("batch_RAW",0);
return; return;
} }
// dialog event and completion callback function // dialog event and completion callback function
int batch_raw_dialog_event(zdialog *zd, cchar *event) int batch_raw_dialog_event(zdialog *zd, ch *event)
{ {
using namespace batch_raw; using namespace batch_raw;
int ii, err, cc; int ii, err, cc;
char countmess[80], *ploc; ch countmess[80], *ploc;
if (strmatch(event,"files")) // select images to convert if (strmatch(event,"files")) // select images to convert
{ {
zdialog_show(zd,0); // hide parent dialog zdialog_show(zd,0); // hide parent dialog
gallery_select(); // get list of files to convert gallery_select(); // get list of files to convert
zdialog_show(zd,1); zdialog_show(zd,1);
snprintf(countmess,80,"%d image files selected",GScount); // stuff count into dialog snprintf(countmess,80,"%d image files selected",GScount); // stuff count into dialog
zdialog_stuff(zd,"fcount",countmess); zdialog_stuff(zd,"fcount",countmess);
} }
skipping to change at line 1655 skipping to change at line 1662
/******************************************************************************* */ /******************************************************************************* */
// Add a small image file over selected host files (for author, copyright, etc. ). // Add a small image file over selected host files (for author, copyright, etc. ).
// Added image position is designated % from host image top and left. // Added image position is designated % from host image top and left.
// Added image width is designated % of host image width. // Added image width is designated % of host image width.
// Added image can have transparency. // Added image can have transparency.
namespace batch_overlay namespace batch_overlay
{ {
char *ovfile = 0; // overlay image file ch *ovfile = 0; // overlay image file
PXB *ovfilepxb = 0; // overlay file PXB PXB *ovfilepxb = 0; // overlay file PXB
int pcttop, pctleft; // overlay position, % from top, % from left, 1-99 int pcttop, pctleft; // overlay position, % from top, % from left, 1-99
int pctwidth; // overlay width, % host ima ge width, 5-95 int pctwidth; // overlay width, % host ima ge width, 5-95
int Fwinadj; // flag, adjust overlay widt h for window size int Fwinadj; // flag, adjust overlay widt h for window size
int winww, winhh; // window size (current or u ser input) int winww, winhh; // window size (current or u ser input)
int Frepl, Fvers; // flags, replace host files or make new versions int Frepl, Fvers; // flags, replace host files or make new versions
}; };
// menu function // menu function
void m_batch_overlay(GtkWidget *, cchar *) // 22.20 void m_batch_overlay(GtkWidget *, ch *) // 22.20
{ {
using namespace batch_overlay; using namespace batch_overlay;
int batch_overlay_dialog_event(zdialog *zd, cchar *event); int batch_overlay_dialog_event(zdialog *zd, ch *event);
zdialog *zd, *zd2; zdialog *zd, *zdpop;
int zstat; int zstat;
char *infile = 0, *outfile = 0; ch *infile = 0, *outfile = 0;
char text[100], *pp; ch text[100], *pp;
int ii, err; int ii, err;
PXM *infilepxm = 0; PXM *infilepxm = 0;
PXB *ovpxb = 0; PXB *ovpxb = 0;
int ovww, ovhh; int ovww, ovhh;
int ovorgx, ovorgy; int ovorgx, ovorgy;
int px1, py1, px2, py2; int px1, py1, px2, py2;
uint8 *pix1; uint8 *pix1;
float *pix2; float *pix2;
float f1, f2; float f1, f2;
float winAR, infileAR; // window and host image ww/hh ratios float winAR, infileAR; // window and host image ww/hh ratios
skipping to change at line 1800 skipping to change at line 1807
zdialog_run(zd,batch_overlay_dialog_event,"parent"); // run dialog zdialog_run(zd,batch_overlay_dialog_event,"parent"); // run dialog
zstat = zdialog_wait(zd); // wait for completion zstat = zdialog_wait(zd); // wait for completion
zdialog_free(zd); zdialog_free(zd);
if (zstat != 1) { // canceled if (zstat != 1) { // canceled
Plog(0,"cancelled \n"); Plog(0,"cancelled \n");
Fblock("batch_overlay",0); Fblock("batch_overlay",0);
return; return;
} }
zd2 = popup_report_open("Processing files",Mwin,600,300,0,0,"OK",0); // log report zdpop = popup_report_open("Processing files",Mwin,600,300,0,0,"OK",0); // log report
for (ii = 0; ii < GScount; ii++) // loop selected files for (ii = 0; ii < GScount; ii++) // loop selected files
{ {
zmainloop(); // keep GTK alive zmainloop(); // keep GTK alive
if (outfile) zfree(outfile); if (outfile) zfree(outfile);
outfile = 0; outfile = 0;
if (infilepxm) PXM_free(infilepxm); if (infilepxm) PXM_free(infilepxm);
infilepxm = 0; infilepxm = 0;
if (zd2->zstat) break; // function canceled if (! zdialog_valid(zdpop)) break; // report canceled 23.1
infile = GSfiles[ii]; // input file infile = GSfiles[ii]; // input file
if (image_file_type(infile) != IMAGE) { if (image_file_type(infile) != IMAGE) {
popup_report_write2(zd2,0,"*** invalid file \n"); popup_report_write2(zdpop,0,"*** invalid file \n");
continue; continue;
} }
popup_report_write2(zd2,0,"\n"); popup_report_write2(zdpop,0,"\n");
popup_report_write2(zd2,0,"%s \n",infile); popup_report_write2(zdpop,0,"%s \n",infile);
// log each input file // log each input file
outfile = f_realpath(infile); // outfile = infile outfile = f_realpath(infile); // outfile = infile
if (! outfile) { if (! outfile) {
popup_report_write2(zd2,0,"*** cannot get real path of input file \n"); popup_report_write2(zdpop,0,"*** cannot get real path of input file \n" );
continue; continue;
} }
if (Fvers) { if (Fvers) {
pp = file_new_version(outfile); // outfile is new version pp = file_new_version(outfile); // outfile is new version
zfree(outfile); zfree(outfile);
outfile = pp; outfile = pp;
if (! outfile) { if (! outfile) {
popup_report_write2(zd2,0,"*** cannot make new version of input file \n"); popup_report_write2(zdpop,0,"*** cannot make new version of input fi le \n");
continue; continue;
} }
} }
infilepxm = PXM_load(infile,0); // load input host file infilepxm = PXM_load(infile,0); // load input host file
if (! infilepxm) { if (! infilepxm) {
popup_report_write2(zd2,0,"*** cannot load input file \n"); popup_report_write2(zdpop,0,"*** cannot load input file \n");
continue; continue;
} }
ovww = 0.01 * pctwidth * infilepxm->ww + 0.5; // overlay width, % host image width ovww = 0.01 * pctwidth * infilepxm->ww + 0.5; // overlay width, % host image width
if (Fwinadj) { // increase overlay width if left/right if (Fwinadj) { // increase overlay width if left/right
infileAR = 1.0 * infilepxm->ww / infilepxm->hh; // margins needed for 'tall' image infileAR = 1.0 * infilepxm->ww / infilepxm->hh; // margins needed for 'tall' image
winAR = 1.0 * winww / winhh; winAR = 1.0 * winww / winhh;
if (winAR > infileAR) ovww = ovww * winAR / infileAR; if (winAR > infileAR) ovww = ovww * winAR / infileAR;
} }
skipping to change at line 1884 skipping to change at line 1891
else f1 = 1.0; else f1 = 1.0;
f2 = 1.0 - f1; f2 = 1.0 - f1;
pix2[0] = f1 * pix1[0] + f2 * pix2[0]; // copy pixel pix2[0] = f1 * pix1[0] + f2 * pix2[0]; // copy pixel
pix2[1] = f1 * pix1[1] + f2 * pix2[1]; pix2[1] = f1 * pix1[1] + f2 * pix2[1];
pix2[2] = f1 * pix1[2] + f2 * pix2[2]; pix2[2] = f1 * pix1[2] + f2 * pix2[2];
} }
err = PXM_save(infilepxm,outfile,f_load_bpc,90,0); err = PXM_save(infilepxm,outfile,f_load_bpc,90,0);
if (err) { if (err) {
popup_report_write2(zd2,0,"*** cannot save output file \n"); popup_report_write2(zdpop,0,"*** cannot save output file \n");
continue; continue;
} }
load_filemeta(outfile); // update image index for output file load_filemeta(outfile); // update image index for output file
update_image_index(outfile); update_image_index(outfile);
popup_report_write2(zd2,0,"*** completed \n"); popup_report_write2(zdpop,0,"*** completed \n");
}
if (! zdialog_valid(zdpop)) {
// 23.1
Plog(0,"*** report cancelled \n");
goto cleanup;
} }
if (zd2->zstat) popup_report_write2(zdpop,0,"\n *** %s \n","COMPLETED");
// popup report canceled popup_report_bottom(zdpop);
popup_report_write2(zd2,0,"\n *** %s \n","function canceled");
else popup_report_write2(zd2,0,"\n *** %s \n","COMPLETED"); cleanup:
popup_report_bottom(zd2);
if (outfile) zfree(outfile); if (outfile) zfree(outfile);
outfile = 0; outfile = 0;
if (infilepxm) PXM_free(infilepxm); if (infilepxm) PXM_free(infilepxm);
infilepxm = 0; infilepxm = 0;
if (ovfilepxb) PXB_free(ovfilepxb); if (ovfilepxb) PXB_free(ovfilepxb);
ovfilepxb = 0; ovfilepxb = 0;
skipping to change at line 1921 skipping to change at line 1933
gallery(navi::galleryname,"init",0); // refresh file list gallery(navi::galleryname,"init",0); // refresh file list
gallery(0,"sort",-2); // recall sort and position gallery(0,"sort",-2); // recall sort and position
gallery(0,"paint",-1); // repaint from same position gallery(0,"paint",-1); // repaint from same position
Fblock("batch_overlay",0); Fblock("batch_overlay",0);
return; return;
} }
// dialog event and completion callback function // dialog event and completion callback function
int batch_overlay_dialog_event(zdialog *zd, cchar *event) int batch_overlay_dialog_event(zdialog *zd, ch *event)
{ {
using namespace batch_overlay; using namespace batch_overlay;
char countmess[80]; ch countmess[80];
char *pp, *ofile; ch *pp, *ofile;
if (zd->zstat) // dialog completed if (zd->zstat) // dialog completed
{ {
if (zd->zstat != 1) return 1; // [cancel] or [x] if (zd->zstat != 1) return 1; // [cancel] or [x]
if (! GScount) { // selected host files count if (! GScount) { // selected host files count
zmessageACK(Mwin,"no host files selected"); zmessageACK(Mwin,"no host files selected");
zd->zstat = 0; zd->zstat = 0;
return 1; return 1;
} }
skipping to change at line 2026 skipping to change at line 2038
return 1; return 1;
} }
/******************************************************************************* */ /******************************************************************************* */
// burn images to DVD/BlueRay optical disc // burn images to DVD/BlueRay optical disc
namespace burn_images namespace burn_images
{ {
zdialog *zd; zdialog *zd;
char mydvd[60]; ch mydvd[60];
}; };
// menu function // menu function
void m_burn_DVD(GtkWidget *, cchar *) void m_burn_DVD(GtkWidget *, ch *)
{ {
using namespace burn_images; using namespace burn_images;
int burn_dialog_event(zdialog *zd, cchar *event); int burn_dialog_event(zdialog *zd, ch *event);
FILE *fid; FILE *fid;
char *pp, text[100]; ch *pp, text[100];
int ii, Fdvd, Ndvd, zstat; int ii, Fdvd, Ndvd, zstat;
cchar *growisofs = "growisofs -Z %s -iso-level 4 -r -path-list %s 2>&1"; ch *growisofs = "growisofs -Z %s -iso-level 4 -r -path-list %s 2>&1";
// growisofs command // growisofs command
char burnlist[200], buffer[200]; ch burnlist[200], buffer[200];
char dvddev[20][4], dvddesc[40][4], dvddevdesc[60][4]; ch dvddev[20][4], dvddesc[40][4], dvddevdesc[60][4];
// up to 4 DVD/BR devices // up to 4 DVD/BR devices
F1_help_topic = "burn DVD/BRD"; F1_help_topic = "burn DVD/BRD";
Plog(1,"m_burn_DVD \n"); Plog(1,"m_burn_DVD \n");
if (! Fgrowisofs) { if (! Fgrowisofs) {
zmessageACK(Mwin,"growisofs not installed"); zmessageACK(Mwin,"growisofs not installed");
return; return;
} }
skipping to change at line 2177 skipping to change at line 2189
if (pp) *pp = 0; if (pp) *pp = 0;
snprintf(command,200,growisofs,mydvd,burnlist); // start burn process snprintf(command,200,growisofs,mydvd,burnlist); // start burn process
popup_command(command,600,400,Mwin); popup_command(command,600,400,Mwin);
return; return;
} }
// dialog event and completion function // dialog event and completion function
int burn_dialog_event(zdialog *zd, cchar *event) int burn_dialog_event(zdialog *zd, ch *event)
{ {
using namespace burn_images; using namespace burn_images;
char countmess[80]; ch countmess[80];
if (strmatch(event,"files")) // select images to burn if (strmatch(event,"files")) // select images to burn
{ {
zdialog_show(zd,0); // hide parent dialog zdialog_show(zd,0); // hide parent dialog
gallery_select(); // get list of files to convert gallery_select(); // get list of files to convert
zdialog_show(zd,1); zdialog_show(zd,1);
snprintf(countmess,80,"%d image files selected",GScount); // update dialog snprintf(countmess,80,"%d image files selected",GScount); // update dialog
zdialog_stuff(zd,"fcount",countmess); zdialog_stuff(zd,"fcount",countmess);
} }
skipping to change at line 2206 skipping to change at line 2218
return 1; return 1;
} }
/******************************************************************************* */ /******************************************************************************* */
// Select files and output a file containing the selected file names. // Select files and output a file containing the selected file names.
namespace imagelist_images namespace imagelist_images
{ {
zdialog *zd; zdialog *zd;
char outfile[300]; ch outfile[300];
}; };
// menu function // menu function
void m_export_filelist(GtkWidget *, cchar *) void m_export_filelist(GtkWidget *, ch *)
{ {
using namespace imagelist_images; using namespace imagelist_images;
int export_filelist_dialog_event(zdialog *zd, cchar *event); int export_filelist_dialog_event(zdialog *zd, ch *event);
FILE *fid; FILE *fid;
int ii, zstat; int ii, zstat;
cchar *title = "Create a file of selected image files"; ch *title = "Create a file of selected image files";
char text[100]; ch text[100];
F1_help_topic = "export file list"; F1_help_topic = "export file list";
Plog(1,"m_export_filelist \n"); Plog(1,"m_export_filelist \n");
if (Fblock(0,"blocked edits")) return; // check nothing pending if (Fblock(0,"blocked edits")) return; // check nothing pending
/*** /***
____________________________________________ ____________________________________________
| Create a file of selected image files | | Create a file of selected image files |
skipping to change at line 2299 skipping to change at line 2311
fprintf(fid,"%s\n",GSfiles[ii]); fprintf(fid,"%s\n",GSfiles[ii]);
fclose(fid); fclose(fid);
zmessageACK(Mwin,"COMPLETED"); zmessageACK(Mwin,"COMPLETED");
return; return;
} }
// dialog event and completion function // dialog event and completion function
int export_filelist_dialog_event(zdialog *zd, cchar *event) int export_filelist_dialog_event(zdialog *zd, ch *event)
{ {
using namespace imagelist_images; using namespace imagelist_images;
char *file; ch *file;
char countmess[80]; ch countmess[80];
if (strmatch(event,"infiles")) // select image files if (strmatch(event,"infiles")) // select image files
{ {
gallery_select(); // get list of files to convert gallery_select(); // get list of files to convert
snprintf(countmess,80,"%d image files selected",GScount); // update dialog snprintf(countmess,80,"%d image files selected",GScount); // update dialog
zdialog_stuff(zd,"Nfiles",countmess); zdialog_stuff(zd,"Nfiles",countmess);
} }
if (strmatch(event,"browse")) if (strmatch(event,"browse"))
{ {
skipping to change at line 2330 skipping to change at line 2342
return 1; return 1;
} }
/******************************************************************************* */ /******************************************************************************* */
// Export selected image files to another folder with optional downsizing. // Export selected image files to another folder with optional downsizing.
// Only the metadata relevant for web photo services is copied. // Only the metadata relevant for web photo services is copied.
namespace export_files_names namespace export_files_names
{ {
char tolocation[500]; ch tolocation[500];
int Fsamesize; int Fsamesize;
int maxww, maxhh; int maxww, maxhh;
int Fmeta; int Fmeta;
}; };
// menu function // menu function
void m_export_files(GtkWidget*, cchar *menu) void m_export_files(GtkWidget*, ch *menu)
{ {
using namespace export_files_names; using namespace export_files_names;
int export_files_dialog_event(zdialog *zd, cchar *event); int export_files_dialog_event(zdialog *zd, ch *event);
zdialog *zd, *zd2; zdialog *zd, *zdpop;
int ii, cc, err, ww, hh, zstat; int ii, cc, err, ww, hh, zstat;
PXM *pxmin, *pxmout; PXM *pxmin, *pxmout;
char *infile, *outfile, *pp, text[100]; ch *infile, *outfile, *pp, text[100];
float scale, wscale, hscale; float scale, wscale, hscale;
#define NK 9 #define NK 9
cchar *keys[NK] = { exif_date_key, iptc_keywords_key, exif_copyright_ke ch *keys[NK] = { meta_date_key, meta_tags_key, meta_copyright_key,
y, meta_description_key, meta_title_key,
iptc_description_key, iptc_title_key, meta_location_key, meta_country_key,
exif_location_key, exif_country_key, meta_lati_key, meta_longi_key };
exif_lati_key, exif_longi_key }; ch *kdata[NK];
char *kdata[NK];
F1_help_topic = "export files"; F1_help_topic = "export files";
Plog(1,"m_export_files \n"); Plog(1,"m_export_files \n");
if (Fblock(0,"blocked edits")) return; // check nothing pending if (Fblock(0,"blocked edits")) return; // check nothing pending
/*** /***
__________________________________________________ __________________________________________________
| Export Files | | Export Files |
skipping to change at line 2407 skipping to change at line 2419
zdialog_stuff(zd,"fcount",text); zdialog_stuff(zd,"fcount",text);
zdialog_resize(zd,400,0); zdialog_resize(zd,400,0);
zdialog_run(zd,export_files_dialog_event,"parent"); // run dialog zdialog_run(zd,export_files_dialog_event,"parent"); // run dialog
zstat = zdialog_wait(zd); // wait for completion zstat = zdialog_wait(zd); // wait for completion
zdialog_free(zd); zdialog_free(zd);
if (zstat != 1) return; // 22.1 if (zstat != 1) return; // 22.1
zadd_locked(Ffuncbusy,+1); zadd_locked(Ffuncbusy,+1);
zd2 = popup_report_open("exporting files",Mwin,600,400,0,0,"OK",0); // log report 22.15 zdpop = popup_report_open("exporting files",Mwin,600,400,0,0,"OK",0); // log report 22.15
for (ii = 0; ii < GScount; ii++) // loop selected files for (ii = 0; ii < GScount; ii++) // loop selected files
{ {
zmainloop(); // keep GTK awake zmainloop(); // keep GTK awake
if (zd2->zstat) break; // function canceled if (! zdialog_valid(zdpop)) break; // report canceled 23.1
infile = GSfiles[ii]; // input filespec infile = GSfiles[ii]; // input filespec
popup_report_write2(zd2,0,"%s \n",infile); popup_report_write2(zdpop,0,"%s \n",infile);
pp = strrchr(infile,'/'); // construct output filespec pp = strrchr(infile,'/'); // construct output filespec
if (! pp) continue; if (! pp) continue;
cc = strlen(pp) + 8; cc = strlen(pp) + 8;
outfile = zstrdup(tolocation,"export files",cc); outfile = zstrdup(tolocation,"export files",cc);
strcat(outfile,pp); strcat(outfile,pp);
pp = strrchr(outfile,'.'); // outfile is type .jpg pp = strrchr(outfile,'.'); // outfile is type .jpg
if (! pp) continue; if (! pp) continue;
strcpy(pp,".jpg"); strcpy(pp,".jpg");
pxmin = PXM_load(infile,0); // read input file pxmin = PXM_load(infile,0); // read input file
if (! pxmin) { if (! pxmin) {
popup_report_write2(zd2,1," *** file type not supported \n"); popup_report_write2(zdpop,1," *** file type not supported \n");
zfree(outfile); zfree(outfile);
continue; continue;
} }
ww = pxmin->ww; // input file size ww = pxmin->ww; // input file size
hh = pxmin->hh; hh = pxmin->hh;
if (Fsamesize) pxmout = pxmin; // same size, output = input if (Fsamesize) pxmout = pxmin; // same size, output = input
else { else {
wscale = hscale = 1.0; wscale = hscale = 1.0;
skipping to change at line 2454 skipping to change at line 2466
if (scale > 0.999) pxmout = pxmin; // no change if (scale > 0.999) pxmout = pxmin; // no change
else { else {
ww = ww * scale; ww = ww * scale;
hh = hh * scale; hh = hh * scale;
pxmout = PXM_rescale(pxmin,ww,hh); // rescaled output file pxmout = PXM_rescale(pxmin,ww,hh); // rescaled output file
PXM_free(pxmin); // free memory PXM_free(pxmin); // free memory
} }
} }
err = PXM_JPG_save(pxmout,outfile,jpeg_def_quality); // write output file err = PXM_JPG_save(pxmout,outfile,jpeg_def_quality); // write output file
if (err) popup_report_write2(zd2,1," *** cannot create new file \n"); if (err) popup_report_write2(zdpop,1," *** cannot create new file \n");
if (! err && Fmeta) { // optional copy metadata if (! err && Fmeta) { // optional copy metadata
err = exif_get(infile,keys,kdata,NK); err = meta_get1(infile,(ch **) keys,kdata,NK);
if (! err) { if (! err) {
err = exif_put(outfile,keys,(cchar **) kdata,NK); err = meta_put(outfile,(ch **) keys,kdata,NK);
if (err) popup_report_write2(zd2,1," *** exif update errpr \n"); // 23.0
// 23.0 if (err) popup_report_write2(zdpop,1," *** metadata update errpr \n"
);
} }
} }
PXM_free(pxmout); PXM_free(pxmout);
zfree(outfile); zfree(outfile);
} }
if (zd2->zstat) if (! zdialog_valid(zdpop)) {
// popup report canceled // 23.1
popup_report_write2(zd2,0,"\n *** function canceled \n"); Plog(0,"*** report cancelled \n");
else popup_report_write2(zd2,0,"\n *** COMPLETED \n"); goto cleanup;
popup_report_bottom(zd2); }
popup_report_write2(zdpop,0,"\n *** COMPLETED \n");
popup_report_bottom(zdpop);
cleanup:
zadd_locked(Ffuncbusy,-1); zadd_locked(Ffuncbusy,-1);
return; return;
} }
// dialog event and completion callback function // dialog event and completion callback function
int export_files_dialog_event(zdialog *zd, cchar *event) int export_files_dialog_event(zdialog *zd, ch *event)
{ {
using namespace export_files_names; using namespace export_files_names;
int cc; int cc;
char countmess[80]; ch countmess[80];
char *ploc; ch *ploc;
if (strmatch(event,"files")) // select files to export if (strmatch(event,"files")) // select files to export
{ {
gallery_select(); // get list of files to convert gallery_select(); // get list of files to convert
snprintf(countmess,80,"%d image files selected",GScount); // update dialog snprintf(countmess,80,"%d image files selected",GScount); // update dialog
zdialog_stuff(zd,"fcount",countmess); zdialog_stuff(zd,"fcount",countmess);
} }
if (strmatch(event,"browse")) { if (strmatch(event,"browse")) {
zdialog_fetch(zd,"toloc",tolocation,500); zdialog_fetch(zd,"toloc",tolocation,500);
skipping to change at line 2533 skipping to change at line 2549
zdialog_fetch(zd,"meta",Fmeta); // metadata option zdialog_fetch(zd,"meta",Fmeta); // metadata option
return 1; return 1;
} }
/******************************************************************************* * /******************************************************************************* *
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: ch 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
***/ ***/
// menu function // menu function
void m_edit_script(GtkWidget *, cchar *menu) void m_edit_script(GtkWidget *, ch *menu)
{ {
int edit_script_dialog_event(zdialog *zd, cchar *event); int edit_script_dialog_event(zdialog *zd, ch *event);
zdialog *zd; zdialog *zd;
F1_help_topic = "script files"; F1_help_topic = "script files";
Plog(1,"m_edit_script \n"); Plog(1,"m_edit_script \n");
if (Fblock(0,"blocked edits")) return; // check nothing pending if (Fblock(0,"blocked edits")) return; // check nothing pending
/*** /***
skipping to change at line 2580 skipping to change at line 2596
zdialog_add_widget(zd,"hbox","hb2","dialog"); zdialog_add_widget(zd,"hbox","hb2","dialog");
zdialog_add_widget(zd,"button","close","hb2","Close","space=5"); zdialog_add_widget(zd,"button","close","hb2","Close","space=5");
zdialog_add_widget(zd,"label","labclose","hb2","finish making a script file") ; zdialog_add_widget(zd,"label","labclose","hb2","finish making a script file") ;
zdialog_run(zd,edit_script_dialog_event,"parent"); zdialog_run(zd,edit_script_dialog_event,"parent");
return; return;
} }
// dialog event and completion function // dialog event and completion function
int edit_script_dialog_event(zdialog *zd, cchar *event) int edit_script_dialog_event(zdialog *zd, ch *event)
{ {
int edit_script_start(void); int edit_script_start(void);
int edit_script_close(void); int edit_script_close(void);
if (strmatch(event,"escape")) zd->zstat = -2; // escape key if (strmatch(event,"escape")) zd->zstat = -2; // escape key
if (zd->zstat) { // cancel if (zd->zstat) { // cancel
zdialog_free(zd); zdialog_free(zd);
if (script_fid) fclose(script_fid); if (script_fid) fclose(script_fid);
script_fid = 0; script_fid = 0;
skipping to change at line 2611 skipping to change at line 2627
} }
return 1; return 1;
} }
// start building a script file // start building a script file
// if Fscriptbuild is active, edit_done() saves edit settings in script file // if Fscriptbuild is active, edit_done() saves edit settings in script file
int edit_script_start() int edit_script_start()
{ {
char *pp; ch *pp;
if (Fblock(0,"blocked edits")) return 0; // check nothing pending if (Fblock(0,"blocked edits")) return 0; // check nothing pending
if (Fscriptbuild) { if (Fscriptbuild) {
zmessageACK(Mwin,"script already started"); zmessageACK(Mwin,"script already started");
return 0; return 0;
} }
pp = zgetfile("start a new script file",MWIN,"save",scripts_folder,1); pp = zgetfile("start a new script file",MWIN,"save",scripts_folder,1);
if (! pp) return 0; if (! pp) return 0;
skipping to change at line 2687 skipping to change at line 2703
script_fid = 0; script_fid = 0;
Fscriptbuild = 0; Fscriptbuild = 0;
zmessageACK(Mwin,"script file closed"); zmessageACK(Mwin,"script file closed");
return 1; return 1;
} }
// present a popup menu for user to select a script file // present a popup menu for user to select a script file
// run the given function using the selected script file // run the given function using the selected script file
// called by m_run_script() and m_batch_script() // called by m_run_script() and m_batch_script()
// //
// 'runfunc' arg: void runfunc(GtkWidget *, cchar *scriptname); // 'runfunc' arg: void runfunc(GtkWidget *, ch *scriptname);
void select_script(cbFunc *runfunc) void select_script(cbFunc *runfunc)
{ {
static char **scriptnames = 0; static ch **scriptnames = 0;
static GtkWidget *scriptmenu = 0; static GtkWidget *scriptmenu = 0;
static int ns = 0; static int ns = 0;
char buff[200], *pp; ch buff[200], *pp;
int ii, kk; int ii, kk;
FILE *fid; FILE *fid;
if (scriptnames) if (scriptnames)
{ {
for (ii = 0; ii < ns; ii++) // free prior memory for (ii = 0; ii < ns; ii++) // free prior memory
zfree(scriptnames[ii]); zfree(scriptnames[ii]);
zfree(scriptnames); zfree(scriptnames);
scriptnames = 0; scriptnames = 0;
} }
skipping to change at line 2740 skipping to change at line 2756
} }
if (kk) popup_menu(0,scriptmenu); // present menu if (kk) popup_menu(0,scriptmenu); // present menu
else zmessageACK(Mwin,"no script files found"); else zmessageACK(Mwin,"no script files found");
return; return;
} }
// execute a script file using the current image file // execute a script file using the current image file
void run_script(GtkWidget *, cchar *scriptname) void run_script(GtkWidget *, ch *scriptname)
{ {
char buff[200]; ch buff[200];
char *pp, menuname[40]; ch *pp, menuname[40];
int ii, err; int ii, err;
if (! curr_file) return; if (! curr_file) return;
if (script_fid) Plog(0,"*** run_script(): script_fid not 0 \n"); if (script_fid) Plog(0,"*** run_script(): script_fid not 0 \n");
if (Fblock(0,"blocked edits")) return; // check nothing pending if (Fblock(0,"blocked edits")) return; // check nothing pending
snprintf(scriptfile,200,"%s/%s",scripts_folder,scriptname); // script file from script name snprintf(scriptfile,200,"%s/%s",scripts_folder,scriptname); // script file from script name
skipping to change at line 2816 skipping to change at line 2832
badfile: badfile:
zmessageACK(Mwin,"script file format error: %s",scriptname); zmessageACK(Mwin,"script file format error: %s",scriptname);
if (script_fid) fclose(script_fid); if (script_fid) fclose(script_fid);
script_fid = 0; script_fid = 0;
Fscriptrun = 0; Fscriptrun = 0;
return; return;
} }
// execute a script file using the pre-selected image files // execute a script file using the pre-selected image files
void batch_script(GtkWidget *, cchar *scriptname) void batch_script(GtkWidget *, ch *scriptname)
{ {
char *imagefile; ch *imagefile;
char *newfilevers; ch *newfilevers;
int ii, err; int ii, err;
if (! GScount) { // preselected file list if (! GScount) { // preselected file list
zmessageACK(Mwin,"no files selected"); zmessageACK(Mwin,"no files selected");
return; return;
} }
for (ii = 0; ii < GScount; ii++) // loop image files to process for (ii = 0; ii < GScount; ii++) // loop image files to process
{ {
imagefile = GSfiles[ii]; imagefile = GSfiles[ii];
skipping to change at line 2856 skipping to change at line 2872
zfree(newfilevers); zfree(newfilevers);
} }
zmessage_post_bold(Mwin,"20/20",3,"script complete"); zmessage_post_bold(Mwin,"20/20",3,"script complete");
return; return;
} }
// menu function // menu function
// select and run a script file using the current image file // select and run a script file using the current image file
void m_run_script(GtkWidget *, cchar *menu) void m_run_script(GtkWidget *, ch *menu)
{ {
F1_help_topic = "script files"; F1_help_topic = "script files";
Plog(1,"m_run_script \n"); Plog(1,"m_run_script \n");
select_script(run_script); select_script(run_script);
return; return;
} }
// menu function // menu function
// select and run a script file using multiple selected files // select and run a script file using multiple selected files
void m_batch_script(GtkWidget *, cchar *menu) void m_batch_script(GtkWidget *, ch *menu)
{ {
int batch_script_dialog_event(zdialog *zd, cchar *event); int batch_script_dialog_event(zdialog *zd, ch *event);
zdialog *zd; zdialog *zd;
char text[100]; ch text[100];
F1_help_topic = "script files"; F1_help_topic = "script files";
Plog(1,"m_batch_script \n"); Plog(1,"m_batch_script \n");
if (Fblock(0,"blocked edits")) return; // check nothing pending if (Fblock(0,"blocked edits")) return; // check nothing pending
/*** /***
_________________________________________ _________________________________________
| Batch Script | | Batch Script |
skipping to change at line 2911 skipping to change at line 2927
snprintf(text,100,"%d image files selected",GScount); // show selected files count snprintf(text,100,"%d image files selected",GScount); // show selected files count
zdialog_stuff(zd,"fcount",text); zdialog_stuff(zd,"fcount",text);
zdialog_run(zd,batch_script_dialog_event,"parent"); zdialog_run(zd,batch_script_dialog_event,"parent");
return; return;
} }
// dialog event and completion function // dialog event and completion function
int batch_script_dialog_event(zdialog *zd, cchar *event) int batch_script_dialog_event(zdialog *zd, ch *event)
{ {
char countmess[80]; ch countmess[80];
F1_help_topic = "script files"; F1_help_topic = "script files";
if (zd->zstat) { // cancel if (zd->zstat) { // cancel
zdialog_free(zd); zdialog_free(zd);
return 1; return 1;
} }
if (strmatch(event,"select-files")) if (strmatch(event,"select-files"))
{ {
 End of changes. 174 change blocks. 
282 lines changed or deleted 299 lines changed or added

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