commit 3a50bf36953ce84c48fba3dd45e72b1483a85b5b Author: Fincer Date: Fri Sep 14 19:45:19 2018 +0300 Initial commit diff --git a/0_cr2hdr_tool/01-patch_tcc_makefile-fix.patch b/0_cr2hdr_tool/01-patch_tcc_makefile-fix.patch new file mode 100644 index 0000000..bd0ea09 --- /dev/null +++ b/0_cr2hdr_tool/01-patch_tcc_makefile-fix.patch @@ -0,0 +1,15 @@ +--- a/magic-lantern/tcc/Makefile ++++ a/magic-lantern/tcc/Makefile +@@ -137,6 +137,12 @@ + TCCLIBS+=$(LIBTCC1_CROSS) + endif + ++#Very bad workaround to solve compilation issues ++CC=../gcc-arm-none-eabi-4_8-2013q4/bin/arm-none-eabi-gcc-4.8.3 ++LD=../gcc-arm-none-eabi-4_8-2013q4/bin/arm-none-eabi-ld ++READELF=../gcc-arm-none-eabi-4_8-2013q4/bin/arm-none-eabi-readelf ++OBJCOPY=../gcc-arm-none-eabi-4_8-2013q4/bin/arm-none-eabi-objcopy ++ + #all: $(PROGS) $(TCCLIBS) $(TCCDOCS) + + all: libtccx.o diff --git a/0_cr2hdr_tool/02_patch_cr2hdr-source_add-dryrun.patch b/0_cr2hdr_tool/02_patch_cr2hdr-source_add-dryrun.patch new file mode 100644 index 0000000..aca90fe --- /dev/null +++ b/0_cr2hdr_tool/02_patch_cr2hdr-source_add-dryrun.patch @@ -0,0 +1,71 @@ +--- a/magic-lantern/modules/dual_iso/cr2hdr.c ++++ b/magic-lantern/modules/dual_iso/cr2hdr.c +@@ -60,6 +60,7 @@ + + /** Command-line interface */ + ++int process_method = 0; + int interp_method = 0; /* 0:amaze-edge, 1:mean23 */ + int chroma_smooth_method = 2; + int fix_pink_dots = 0; +@@ -98,7 +99,13 @@ + + void check_shortcuts() + { +- if (shortcut_fast) ++ if (process_method == 1) ++ { ++ interp_method = 2; ++ chroma_smooth_method = 1; ++ gray_wb = 5; ++ } ++ else if (shortcut_fast) + { + interp_method = 1; + chroma_smooth_method = 0; +@@ -129,6 +136,13 @@ + + struct cmd_group options[] = { + { ++ "Processing methods", (struct cmd_option[]) { ++ { &process_method, 0, "--process", "Process Dual ISO compatible file (default)" }, ++ { &process_method, 1, "--dry-run", "Only check file for Dual ISO presence" }, ++ OPTION_EOL ++ }, ++ }, ++ { + "Shortcuts", (struct cmd_option []) { + { &shortcut_fast, 1, "--fast", "disable most postprocessing steps (fast, but low quality)\n" + " (--mean23, --no-cs, --no-fullres, --no-alias-map, --no-stripe-fix, --no-bad-pix)" }, +@@ -870,12 +884,12 @@ + whites[num_files] = raw_info.white_level; + num_files++; + } +- else ++ else if (process_method != 1) + { + printf("ISO blending didn't work\n"); + } + } +- else ++ else if (process_method != 1) + { + printf("Doesn't look like interlaced ISO\n"); + } +@@ -2206,7 +2220,15 @@ + double corr_ev = 0; + int white_darkened = white_bright; + int ok = match_exposures(&corr_ev, &white_darkened); +- if (!ok) goto err; ++ if (!ok) ++ { ++ goto err; ++ } ++ else if (ok && process_method == 1) ++ { ++ printf("Interlaced ISO detected\n"); /*. File: %s\n", filename);*/ ++ return 0; ++ } + + /* run a second black subtract pass, to fix whatever our funky processing may do to blacks */ + black_subtract_simple(raw_info.active_area.x1, raw_info.active_area.y1); diff --git a/0_cr2hdr_tool/03_patch_add_baseline-exif.patch b/0_cr2hdr_tool/03_patch_add_baseline-exif.patch new file mode 100644 index 0000000..73221d9 --- /dev/null +++ b/0_cr2hdr_tool/03_patch_add_baseline-exif.patch @@ -0,0 +1,11 @@ +--- a/magic-lantern/modules/dual_iso/exiftool-bridge.c ++++ a/magic-lantern/modules/dual_iso/exiftool-bridge.c +@@ -10,7 +10,7 @@ + { + char exif_cmd[1000]; + printf("%-16s: copying EXIF from %s\n", dest, source); +- snprintf(exif_cmd, sizeof(exif_cmd), "exiftool -tagsFromFile \"%s\" -all:all \"-xmp:subject=Dual-ISO\" \"-UniqueCameraModel + +pkgname=magiclantern-tools +pkgver=1 +pkgrel=1 +pkgdesc="Magic Lantern image processing tools for Canon DSLR's with Magic Lantern firmware." +arch=('any') +url='https://bitbucket.org/hudson/magic-lantern' +license=("GPL") +depends=('perl-image-exiftool' 'dcraw') +optdepends=('octave') +makedepends=('mercurial') + +#REQUIRED BY MODULES +#Use these dependencies only if you try compile more modules. They rely partially on rst2html5 package. +#makedepends=rst2html5 python-docutils + +arm_compiler=gcc-arm-none-eabi-4_8-2013q4 +source=( +#https://launchpad.net/gcc-arm-embedded/4.8/4.8-2013-q4-major/+download/$arm_compiler-20131204-linux.tar.bz2 +gcc-arm-none-eabi-4_8-2013q4-20131204-linux.tar.bz2 #local source +magic-lantern_source_30092017.tar.bz2 #local source +Makefile.user +01-patch_tcc_makefile-fix.patch +02_patch_cr2hdr-source_add-dryrun.patch +03_patch_add_baseline-exif.patch +04_patch_cr2hdr_disable-strings.patch +05_patch_modules-makefile_disable-strings.patch +) +md5sums=('4869e6a6e1dc11ea0835e8b8213bb194' + '5f32b3c128cccebdac1520d442b95c95' + '035e3049e5f3205680566ffc6c6e9023' + '2adcdf6ed3a6cec7b7594ef310d5737a' + '2a921d40e65004bb0f9f4d274b83ff04' + '317c4ce8317182a98700b57b285ef184' + 'd2e57664cbc7310521eee4b0b13a3f41' + '25281350b6a5a9f40a1b40933f0de829') + +prepare() { + cd "$srcdir"/ + + ##### + #Download Magic Lantern latest source files + #hg clone -r unified https://bitbucket.org/hudson/magic-lantern + ##### + + #This is an ugly hack, I know. Make sure you update the patch file if you change ARM compiler + patch -Np1 -i "$srcdir"/01-patch_tcc_makefile-fix.patch + + #Implement Dry Run feature in CR2HDR + patch -Np1 -i "$srcdir"/02_patch_cr2hdr-source_add-dryrun.patch + + #Write Baseline Exposure values to EXIF tags: + patch -Np1 -i "$srcdir"/03_patch_add_baseline-exif.patch + + #All modules have python issues (outdated code?) so they don't compile. The problem is related to version etc. strings. Just disable them and compile the code. Only used for cr2hdr (as we need it, not other modules) + patch -Np1 -i "$srcdir"/04_patch_cr2hdr_disable-strings.patch + patch -Np1 -i "$srcdir"/05_patch_modules-makefile_disable-strings.patch + + #Custom compilation settings for Magic Lantern (Mainly ARM compiler path redefinition) + ln -s "$srcdir"/Makefile.user "$srcdir"/magic-lantern/Makefile.user + + #Link downloaded ARM compiler files to Magic Lantern directory + ln -s "$srcdir"/$arm_compiler "$srcdir"/magic-lantern/$arm_compiler +} + +build() { + cd "$srcdir"/magic-lantern #/modules/dual_iso + +####################################### +# FIRMWARE - MODULES FAIL TO BUILD DUE TO PYTHON ISSUES + + ##make 5D3 #5D Mark 3 - Both firmwares - DOESN'T INCLUDE MODULES YET + ##make 5D3.113 #5D Mark 3 - Firmware 1.1.3 - DOESN'T INCLUDE MODULES YET + + #make 5D3.123 #5D Mark 3 - Firmware 1.2.3 - DOESN'T INCLUDE MODULES YET + #mkdir -p "$startdir"/5dmark3_firmware_123/ + #cp "$srcdir"/magic-lantern/platform/5D3.123/{autoexec.bin,ML-SETUP.FIR} "$startdir"/5dmark3_firmware_123/ #magiclantern.bin,version.bin + +####################################### +# MODULES + + #make all_modules #All modules - FAIL TO BUILD DUE TO PYTHON ISSUES + +#CR2HDR application for host computer + cd "$srcdir"/magic-lantern/modules/dual_iso + make cr2hdr + cd .. + +#MLV_DUMP application for host computer + cd "$srcdir"/magic-lantern/modules/mlv_rec + make mlv_dump + cd .. + +} + +package() +{ +mkdir -p "$pkgdir"/usr/bin +cp "$srcdir"/magic-lantern/modules/dual_iso/cr2hdr "$pkgdir"/usr/bin +cp "$srcdir"/magic-lantern/modules/mlv_rec/mlv_dump "$pkgdir"/usr/bin/mlvdump +} diff --git a/0_cr2hdr_tool/README.md b/0_cr2hdr_tool/README.md new file mode 100644 index 0000000..f128493 --- /dev/null +++ b/0_cr2hdr_tool/README.md @@ -0,0 +1,57 @@ +# Magic Lantern cr2hdr tool - customized + +This directory contains files to compile Magic Lantern cr2hdr dual ISO conversion tool on Linux (Arch Linux preferred). + +Patches in this directory have some custom features which are not found in the original cr2hdr version. These features include: + +- added support for `--dry-run` parameter for cr2hdr + + - When `--dry-run` is enabled, the actual conversion is not done. The tool just checks that conversion is possible + + - This is handy in scripts where we just want to distinguish normal single ISO CR2 files from Dual ISO ones and then perform some custom action + +- added support for `baseline` metadata export. Following tags are exported: + + - Baseline Exposure (sample value: 0.25) + + - Baseline Noise (sample value: 0.8) + + - Baseline Sharpness (sample value: 1.2) + + - These values affect RAW image post-processing + + - [More about the meaning of Baseline values](https://www.rawdigger.com/howtouse/deriving-hidden-ble-compensation) + +## Custom patches + +### 01-patch_tcc_makefile-fix.patch + +- A very bad workaround for solving compilation issues (hard-links some required stuff) + +### 02_patch_cr2hdr-source_add-dryrun.patch + +- Add dry run implementation for cr2hdr + +### 03_patch_add_baseline-exif.patch + +- Add baseline exif tags for converted dual ISO files (DNG format) + +### 04_patch_cr2hdr_disable-strings.patch + +- Remove some unnecessary and Windows-specific strings from cr2hdr entries + +### 05_patch_modules-makefile_disable-strings.patch + +- Disable `module_strings.h` in a cr2hdr modules file + +## Working cr2hdr and other software versions - archives + +The following versions have been tested: + + - gcc-arm-none-eabi-4_8-2013q4-20131204-linux.tar.bz2 + + - MD5sum: 4869e6a6e1dc11ea0835e8b8213bb194 + + - magic-lantern_source_30092017.tar.bz2 + + - MD5sum: 1df9f79ad7e549d95f0065d3d00247f4 diff --git a/1_magiclantern_bootablecard_linux/PKGBUILD b/1_magiclantern_bootablecard_linux/PKGBUILD new file mode 100644 index 0000000..b4902b3 --- /dev/null +++ b/1_magiclantern_bootablecard_linux/PKGBUILD @@ -0,0 +1,26 @@ +# Maintainer: Pekka Helenius + +# Source code files by Trammell Hudson // Magic Lantern + +pkgname=magiclantern-bootablecard +pkgver=1 +pkgrel=1 +pkgdesc='Create a Magic Lantern compatible SD card for Canon EOS cameras (enable boot flag).' +arch=('i686' 'x86_64') +license=('GPL') +url='https://bitbucket.org/hudson/magic-lantern/src/tip/contrib/make-bootable/' +depends=('exfat-dkms-git' 'coreutils' 'exfat-utils-nofuse' 'util-linux') +makedepends=('gcc') +source=(magiclantern-bootablecard.tar.gz) +md5sums=('50a78cd16d2d05b78c0273fe53a59236') + +build() { + gcc exfat_sum.c -I$srcdir/modules/lua/dietlibc/include/ -o $srcdir/exfat_sum +} + +package() { + mkdir -p $pkgdir/usr/bin/ + install -m755 $srcdir/{make_bootable.sh,exfat_sum} $pkgdir/usr/bin/ + mv $pkgdir/usr/bin/make_bootable.sh $pkgdir/usr/bin/ml-bootablecard + chmod +x $pkgdir/usr/bin/ml-bootablecard +} diff --git a/1_magiclantern_bootablecard_linux/README.md b/1_magiclantern_bootablecard_linux/README.md new file mode 100644 index 0000000..99ab5d0 --- /dev/null +++ b/1_magiclantern_bootablecard_linux/README.md @@ -0,0 +1,13 @@ +# Magic Lantern bootable card on Linux + +Create a bootable Magic Lantern compatible SD card for Canon DSLRs on Linux. Adds necessary boot flag to the card. + +## PKGBUILD + +Arch Linux specific script file to compile this tool from source + +## magiclantern-bootablecard.tar.gz + +Contains files which are released under GPL at: + +[Trammell Hudson - Magic Lantern: make-bootable // bitbucket.org](https://bitbucket.org/hudson/magic-lantern/src/tip/contrib/make-bootable/) \ No newline at end of file diff --git a/1_magiclantern_bootablecard_linux/magiclantern-bootablecard.tar.gz b/1_magiclantern_bootablecard_linux/magiclantern-bootablecard.tar.gz new file mode 100644 index 0000000..0bf248e Binary files /dev/null and b/1_magiclantern_bootablecard_linux/magiclantern-bootablecard.tar.gz differ diff --git a/2_gnuplot_patch/patch_modify-qt-window.patch b/2_gnuplot_patch/patch_modify-qt-window.patch new file mode 100644 index 0000000..5943cac --- /dev/null +++ b/2_gnuplot_patch/patch_modify-qt-window.patch @@ -0,0 +1,31 @@ +--- a/src/qtterminal/QtGnuplotWindow.cpp ++++ b/src/qtterminal/QtGnuplotWindow.cpp +@@ -113,11 +113,14 @@ + exportMenu->addAction(exportPngAction); + exportAction->setMenu(exportMenu); + m_toolBar->addAction(exportAction); +- createAction(tr("Replot") , 'e', ":/images/replot"); + createAction(tr("Show grid") , 'g', ":/images/grid"); + createAction(tr("Previous zoom"), 'p', ":/images/zoomPrevious"); + createAction(tr("Next zoom") , 'n', ":/images/zoomNext"); +- createAction(tr("Autoscale") , 'a', ":/images/autoscale"); ++ createAction(tr("Reset Zoom") , 'u', ":/images/autoscale"); ++ //createAction(tr("Autoscale") , 'a', ":/images/autoscale"); ++ createAction(tr("Invert plots") , 'i', ":/images/invert"); ++ createAction(tr("Hide all plots") , 'V', ":/images/hide"); ++ createAction(tr("Show all plots") , 'v', ":/images/replot"); + m_toolBar->addAction(settingsAction); + + loadSettings(); +--- a/src/qtterminal/QtGnuplotResource.qrc ++++ b/src/qtterminal/QtGnuplotResource.qrc +@@ -13,5 +13,7 @@ + images/zoom-in.png + images/zoom-original.png + images/configure.png ++ images/view-hide.png ++ images/view-invert.png + +- +\ No newline at end of file ++ diff --git a/3_desktop_files_for_kde-plasma-dolphin/01_imagetools-statistics.desktop b/3_desktop_files_for_kde-plasma-dolphin/01_imagetools-statistics.desktop new file mode 100644 index 0000000..60356b6 --- /dev/null +++ b/3_desktop_files_for_kde-plasma-dolphin/01_imagetools-statistics.desktop @@ -0,0 +1,14 @@ +[Desktop Entry] +Type=Service +ServiceTypes=KonqPopupMenu/Plugin +Icon=application-x-theme +MimeType=image/x-canon-cr2;image/x-adobe-dng;text/csv; +Actions=statistics; +X-KDE-StartupNotify=false +X-KDE-Priority=TopLevel +X-KDE-Submenu=Image Tools + +[Desktop Action statistics] +Name=Statistics +Icon=application-x-theme +Exec=/usr/share/kservices5/ServiceMenus/imagetools_01_exif_statistics.sh %F diff --git a/3_desktop_files_for_kde-plasma-dolphin/02_imagetools-dng-cr2.desktop b/3_desktop_files_for_kde-plasma-dolphin/02_imagetools-dng-cr2.desktop new file mode 100644 index 0000000..a55c7d5 --- /dev/null +++ b/3_desktop_files_for_kde-plasma-dolphin/02_imagetools-dng-cr2.desktop @@ -0,0 +1,19 @@ +[Desktop Entry] +Type=Service +ServiceTypes=KonqPopupMenu/Plugin +Icon=application-x-theme +MimeType=image/x-canon-cr2;image/x-adobe-dng; +Actions=convert_dualiso;raw_tags; +X-KDE-StartupNotify=false +X-KDE-Priority=TopLevel +X-KDE-Submenu=Image Tools + +[Desktop Action convert_dualiso] +Name=Detect & convert Dual ISO +Icon=application-x-theme +Exec=/usr/share/kservices5/ServiceMenus/imagetools_02_dualiso.sh %F + +[Desktop Action raw_tags] +Name=Rename, Uncrop & Add Baseline Tags +Icon=application-x-theme +Exec=/usr/share/kservices5/ServiceMenus/imagetools_03_raw_resolution-baseline.sh %F diff --git a/3_desktop_files_for_kde-plasma-dolphin/03_imagetools-mlv.desktop b/3_desktop_files_for_kde-plasma-dolphin/03_imagetools-mlv.desktop new file mode 100644 index 0000000..0abecd0 --- /dev/null +++ b/3_desktop_files_for_kde-plasma-dolphin/03_imagetools-mlv.desktop @@ -0,0 +1,19 @@ +[Desktop Entry] +Type=Service +ServiceTypes=KonqPopupMenu/Plugin +Icon=application-x-theme +MimeType=x-canon-mlv; +Actions=mlvdump;mlvinfo; +X-KDE-StartupNotify=false +X-KDE-Priority=TopLevel +X-KDE-Submenu=Image Tools + +[Desktop Action mlvdump] +Name=Extract all DNG frames +Icon=application-x-theme +Exec=/usr/share/kservices5/ServiceMenus/imagetools_05_mlvdump.sh %F + +[Desktop Action mlvinfo] +Name=About this MLV file +Icon=application-x-theme +Exec=/usr/share/kservices5/ServiceMenus/imagetools_06_mlvinfo.sh %F diff --git a/3_desktop_files_for_kde-plasma-dolphin/04_imagetools-jpg-png.desktop b/3_desktop_files_for_kde-plasma-dolphin/04_imagetools-jpg-png.desktop new file mode 100644 index 0000000..ba87bb5 --- /dev/null +++ b/3_desktop_files_for_kde-plasma-dolphin/04_imagetools-jpg-png.desktop @@ -0,0 +1,19 @@ +[Desktop Entry] +Type=Service +ServiceTypes=KonqPopupMenu/Plugin +Icon=application-x-theme +MimeType=image/jpeg;image/png; +Actions=exif_deletedata;exif_deletedata_critical; +X-KDE-StartupNotify=false +X-KDE-Priority=TopLevel +X-KDE-Submenu=Image Tools + +[Desktop Action exif_deletedata] +Name=Delete EXIF metadata +Icon=application-exit +Exec=/usr/share/kservices5/ServiceMenus/imagetools_06_exif_deletedata.sh %F + +[Desktop Action exif_deletedata_critical] +Name=Delete critical EXIF metadata +Icon=application-exit +Exec=/usr/share/kservices5/ServiceMenus/imagetools_06_exif_deletedata_critical.sh %F diff --git a/3_desktop_files_for_kde-plasma-dolphin/05_imagetools-imagestack.desktop b/3_desktop_files_for_kde-plasma-dolphin/05_imagetools-imagestack.desktop new file mode 100644 index 0000000..0904251 --- /dev/null +++ b/3_desktop_files_for_kde-plasma-dolphin/05_imagetools-imagestack.desktop @@ -0,0 +1,14 @@ +[Desktop Entry] +Type=Service +ServiceTypes=KonqPopupMenu/Plugin +Icon=application-x-theme +MimeType=image/tiff; +Actions=ale_imagestack; +X-KDE-StartupNotify=false +X-KDE-Priority=TopLevel +X-KDE-Submenu=Image Tools + +[Desktop Action ale_imagestack] +Name=Stack TIFF images +Icon=application-exit +Exec=/usr/share/kservices5/ServiceMenus/imagetools_07_ale_stack.sh %f diff --git a/4_scripts/0-PUT-DESKTOP-FILES-HERE b/4_scripts/0-PUT-DESKTOP-FILES-HERE new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/4_scripts/0-PUT-DESKTOP-FILES-HERE @@ -0,0 +1 @@ + diff --git a/4_scripts/PKGBUILD b/4_scripts/PKGBUILD new file mode 100644 index 0000000..53de5c2 --- /dev/null +++ b/4_scripts/PKGBUILD @@ -0,0 +1,49 @@ +# Maintainer: Pekka Helenius + +pkgname=kde-servicemenus-imagetools +pkgver=1 +pkgrel=1 +pkgdesc="Useful combination of tools for processing various images (KDE5 Dolphin action)" +url=() +arch=('any') +license=('GPL') +install='' +source=(imagetools_01_exif_statistics.sh +imagetools_02_dualiso.sh +imagetools_03_raw_resolution-baseline.sh +imagetools_04_mlvdump.sh +imagetools_05_mlvinfo.sh +imagetools_06_exif_deletedata.sh +imagetools_06_exif_deletedata_critical.sh +imagetools_07_ale_stack.sh +01_imagetools-statistics.desktop +02_imagetools-dng-cr2.desktop +03_imagetools-mlv.desktop +04_imagetools-jpg-png.desktop +05_imagetools-imagestack.desktop) +#xwinkill) #Workaround for bug: https://sourceforge.net/p/gnuplot/bugs/1659/ +depends=('magiclantern-tools' 'perl-image-exiftool' 'ale' 'dcraw' 'netpbm' 'gnuplot' 'coreutils' 'dolphin') +optdepends=() +conflicts=() +makedepends=() + +md5sums=('b4c1f2f5906a56c5cd5404415b26ad5b' + 'a84bf74fb67a5f6f2289ebee2ce4452e' + '6e81d48727e7fc6922a2aed0ce7810c1' + 'a7e0c36553ff59d182460a2108163798' + '01756513818969a07ff61a1ee648106b' + '75588a9f375ac5c6f6f245d12cc315d5' + 'c294e69b9f6e714a307306fd4301fd61' + '88cbadd0f290c737f7f0660a7029029d' + '93bb82eec8ead83b5b5369822d44d780' + '940848e05d6c6400eac97a998fb0f26b' + 'be883bb11a24c4f7ac6452f3cab6cf66' + '9170a5e116fc2eede5325d0a985931dc' + '531f2b73b8514430a772a61a10de097f') + +package() { + mkdir -p $pkgdir/usr/share/kservices5/ServiceMenus/ + cp $srcdir/{imagetools_01_exif_statistics.sh,imagetools_02_dualiso.sh,imagetools_03_raw_resolution-baseline.sh,imagetools_04_mlvdump.sh,imagetools_05_mlvinfo.sh,imagetools_06_exif_deletedata.sh,imagetools_06_exif_deletedata_critical.sh,imagetools_07_ale_stack.sh,01_imagetools-statistics.desktop,02_imagetools-dng-cr2.desktop,03_imagetools-mlv.desktop,04_imagetools-jpg-png.desktop,05_imagetools-imagestack.desktop} $pkgdir/usr/share/kservices5/ServiceMenus/ + chmod 755 $pkgdir/usr/share/kservices5/ServiceMenus/{imagetools_01_exif_statistics.sh,imagetools_02_dualiso.sh,imagetools_03_raw_resolution-baseline.sh,imagetools_04_mlvdump.sh,imagetools_05_mlvinfo.sh,imagetools_06_exif_deletedata.sh,imagetools_06_exif_deletedata_critical.sh,imagetools_07_ale_stack.sh,01_imagetools-statistics.desktop,02_imagetools-dng-cr2.desktop,03_imagetools-mlv.desktop,04_imagetools-jpg-png.desktop,05_imagetools-imagestack.desktop} + #chmod +x $pkgdir/usr/share/kservices5/ServiceMenus/xwinkill +} diff --git a/4_scripts/imagetools_01_exif_statistics.sh b/4_scripts/imagetools_01_exif_statistics.sh new file mode 100644 index 0000000..223914c --- /dev/null +++ b/4_scripts/imagetools_01_exif_statistics.sh @@ -0,0 +1,1220 @@ +#!/bin/bash + +# Statistics of camera RAW images with GNU Plot & Exiftool +# Copyright (C) 2017 Pekka Helenius +# +# 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 the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +############################################### + +# TODO list: + +# TODO Add message, either of these: +# If not a geotagged image file: +# A You haven't geotagged selected photos. Are you sure you want to continue? +# B Following photos don't have altitude value: XX XX XX Are you sure you want to continue? + +# TODO IF INPUT IS A CSV FILE, DO NOT SUGGEST 'EXPORT ONLY' AS AN OPTION + +# TODO if user chooses alternative 'Export CSV' only, do not crash if errtags or errnames encountered + +# +# TODO Be more specific in which case errtags may crash the operation. For instance, if user has chosen only Temperature and ISO to be plotted on GNU Plot, do not crash in case where Focal Length is missing. In other words: be more specific in which conditions match the crash requirement, do not crash the process for nothing. + +# TODO The script has only been tested on Canon 5D Mark 3 CR2 files. How does the script work with other Canon camera models? And what about Sony, Nikon? +# + +# TODO Re-write, parse and simplify some scripts logics! + +############################################### + +# Supported & tested camera raw pictures: +# Canon EOS 5D Mark 3 + +# TOOL REQUIREMENTS +# perl-exiftool +# kdialog (Qt5) +# qt5-tools (qdbus) +# coreutils (md5sum, echo etc..) +# netpbm (pgmhist) +# dcraw +# gawk +# gnuplot (+ Qt interface) +# +# +# OTHER REQUIREMENTS +# +# Recommended: Qt5 Dolphin file manager (dolphin) +# +# This script is meant to be run as a Dolphin File Manager script (Qt5). It gets file arguments straight from Dolphin +# You can run the script in bash (or execute Dolphin via bash) to get detailed script output (CLI messages, debug messages etc.) +# + +#BRACKETS AND QUOTATION MARKS ARE USED IN THIS SCRIPT BECAUSE FOLDER AND FILE PATHS MAY CONTAIN SPACES! + +####################################################################### +# VARIABLES FOR THE SCRIPT + +CSV_FILECOUNT=$(printf '%s\n' "${@}" | rev | cut -f 1 -d '.' | rev | grep -i "csv" | wc -l) +RAW_FILECOUNT=$(printf '%s\n' "${@}" | rev | cut -f 1 -d '.' | rev | grep -i -E "cr2|nef|dng" | wc -l) + +COLUMNCOUNT=24 #Count of all columns must be found in CSV file. This number must match with the number found in kdialog processing dialog below. + +####################################################################### +# 1ST FILE CHECK + +if [[ "${@}" == "" ]]; then + kdialog --error "Not any files selected!"; + exit +elif [[ ! $CSV_FILECOUNT == 0 ]] && [[ ! $RAW_FILECOUNT == 0 ]]; then + kdialog --error "Select only RAW files or a single CSV file!"; + exit +elif [[ $CSV_FILECOUNT -gt 1 ]]; then + kdialog --error "Select only one CSV file!"; + exit +elif [[ $RAW_FILECOUNT == 1 ]]; then + kdialog --error "Please select at least 2 valid RAW files or a CSV file!"; + exit +elif [[ $RAW_FILECOUNT == 0 ]] && [[ $CSV_FILECOUNT == 0 ]]; then + kdialog --error "Please select valid RAW files or a CSV file!"; + exit +fi + +####################################################################### + +# KDIALOG CHECK LIST FORMATTED SELECTION WINDOW + +if [[ $RAW_FILECOUNT == 0 ]] && [[ $CSV_FILECOUNT == 1 ]]; then + + SELECTION=$(kdialog --checklist "Select statistics to display:" \ + 1 "" off \ + 2 "" off \ + 3 "Temperatures & ISOs" on \ + 4 "" off \ + ); + + # 1 Apertures, Exposures & ISOs + # 2 Focal Lengths & Lenses + # 3 Temperatures & ISOs + # 4 Shooting & Focus Modes + + if [ "$?" = 0 ]; then + if [ $(expr length "$SELECTION") != 0 ]; then + for result in $SELECTION + do + if [ $result = '"1"' ]; then + SEL1=true + fi + if [ $result = '"2"' ]; then + SEL2=true + fi + if [ $result = '"3"' ]; then + SEL3=true + fi + if [ $result = '"4"' ]; then + SEL4=true + fi + done + else + kdialog --sorry "Aborted"; + fi + elif [ "$?" = 1 ]; then + exit 0 + else + kdialog --error "Unexpected Error"; + fi + + SEL5=false +fi + +if [[ $RAW_FILECOUNT != 0 ]] && [[ $CSV_FILECOUNT == 0 ]]; then + + SELECTION=$(kdialog --checklist "Select statistics to display:" \ + 1 "" off \ + 2 "" off \ + 3 "Temperatures & ISOs" on \ + 4 "" off \ + 5 "Export Only (CSV)" off \ + ); + + # 1 Apertures, Exposures & ISOs + # 2 Focal Lengths & Lenses + # 3 Temperatures & ISOs + # 4 Shooting & Focus Modes + # 5 Export Only (CSV) + + if [ "$?" = 0 ]; then + if [ $(expr length "$SELECTION") != 0 ]; then + for result in $SELECTION + do + if [ $result = '"1"' ]; then + SEL1=true + fi + if [ $result = '"2"' ]; then + SEL2=true + fi + if [ $result = '"3"' ]; then + SEL3=true + fi + if [ $result = '"4"' ]; then + SEL4=true + fi + if [ $result = '"5"' ]; then #If checked, we force all other values to be false + SEL5=true + SEL4=false + SEL3=false + SEL2=false + SEL1=false + fi + done + else + kdialog --sorry "Aborted"; + fi + elif [ "$?" = 1 ]; then + exit 0 + else + kdialog --error "Unexpected Error"; + fi +fi + +# SEL1 = "Apertures, Exposures & ISOs" true/false +# SEL2 = "Focal Lengths & Lenses" true/false +# SEL3 = "Temperatures & ISOs" true/false +# SEL4 = "Shooting & Focus Modes" true/false +# SEL5 = "Export Only (CSV)" true/false + +####################################################################### + +#We get the directory just from the first filename. Pwd should be easier, but bugged, so... +INPUT_DIR=$(dirname "${1}") +DIR_BASENAME=$(echo -n "${INPUT_DIR}" | rev | cut -d'/' -f 1 | rev) + +#First & Last file names (without suffixes) +for last; do true; done +FIRST=$(basename "${1}" | cut -f 1 -d '.') #Name of the first file passed into the script +LAST=$(basename "${last}" | cut -f 1 -d '.') #Name of the last file passed into the script + +#File name is based on the folder where files exist +FILENAME=$(echo "${DIR_BASENAME}-${FIRST}-${LAST}_metadata") +FILE_EXT=.csv + +#Sed is here to remove any trailing spaces and crap like blank lines +INPUT_FILESYSTEM=$(df -h "${1}" | awk -F ' ' 'FNR> 1 {print $1}' | grep -i -E "/dev/sd?|/dev/hd?|?rewritefs|/dev/nvme?" | sed '/^\s*$/d' | wc -l) + +####################################################################### +# 2ND FILE CHECK + +# Check if we are dealing with a CSV file or bunch of RAW files. + +if [[ $CSV_FILECOUNT == 1 ]]; then + + FILENAME=$(basename "${1}" | sed 's/\.\w*$//') #without a suffix. #We use valid existing CSV file name here + CSVFOLDER="${INPUT_DIR}" #We don't need to redirect this folder path to $HOME because we assume this file already exists + +# If the first input file is not CSV but a RAW file, then we check the filesystem of this file and decide whether to use $HOME folder or picture folder for a new CSV file. +# We don't need this check for any CSV files, because we just extract information from them, not any write operations are required. +elif [[ $RAW_FILECOUNT != 0 ]]; then + echo "Multiple RAW files." + if [[ "${INPUT_FILESYSTEM}" -eq 0 ]]; then #if input file (first file printed in bash) filesystem does not start with /dev/sdX + CSVFOLDER="${HOME}" + kdialog --msgbox "Images are in a SD Card. Writing EXIF CSV data file to ${HOME}/" + # TODO If we have exactly same files selected in SD card but we don't have CSV file in home folder, this doesn't work as expected. It assumes the file to be checked is in home folder. + else + CSVFOLDER="${INPUT_DIR}" + fi +fi + +RAWDATA_TMP="${CSVFOLDER}/${FILENAME}${FILE_EXT}" + +####################################################################### + +# 1) CHECK CSV FILE VALIDITY AGAINST THE SCRIPT OUTPUT +# 2) GET VALUE FOR 'INPUT_FILES_MD5SUM' VARIABLE + +# NOTE: We don't check MD5Sums, if we use CSV file as an input. Though this file can exist in the same folder with the pictures, we want to keep CSV files as portable as possible in general. +# Thus, we don't do the following check: CSV file list MD5Sums vs actual corresponding files in the folder (if only CSV is selected as input). This can arise other problems such as images +# with equivalent names listed in CSV file but they are actually different files. This causes mismatch between CSV file content and folder content. So, no go. + +# 1) Check validity of the selected CSV file for analysis purposes. Not RAW files selected. +if [[ -e "${RAWDATA_TMP}" ]]; then # Referring to existing CSV file here. User input may or may not be a CSV file, so we don't check it. + + echo "This is a valid CSV file. Checking columns." + + FILE_COLUMNCOUNT=$(echo -n $(awk -F ',' '{print NF}' "${RAWDATA_TMP}" | sort -nu)) #This *must* return only one value (equal to COLUMNCOUNT). If many values are returned CSV file can't be used because, therefore, there are mismatch between column numbers in rows. + FILE_HASMD5COLUMN=$(awk -F ',' '{print $2}' "${RAWDATA_TMP}" | head -n 1) + FILE_MD5_CHARNUM=$(echo -n $(awk -F ',' ' FNR > 1 {print length($2)}' "${RAWDATA_TMP}" | sort -nu)) #This *must* return only one value. Value 32. + + # If the input csv file has valid count of columns and the second column includes md5sums. + if [[ $FILE_COLUMNCOUNT -eq $COLUMNCOUNT ]] && [[ $FILE_HASMD5COLUMN == "File MD5Sum" ]] && [[ $FILE_MD5_CHARNUM == 32 ]]; then + COLUMNS_OK=true + echo "Columns OK, continuing." + elif [[ $RAW_FILECOUNT == 0 ]]; then + echo -e "Charnum is:$FILE_MD5_CHARNUM" + echo "Error in columns." + kdialog --error "Error in CSV file columns!"; + exit + else + echo "Error in matching file columns. RAW files as input." + COLUMNS_OK=false #This is a case where we have detected a pattern matcing CSV file but it has invalid columns. + fi +fi + +# 2) Instead of single CSV file, if multiple RAW files have been selected, then +if [[ $RAW_FILECOUNT != 0 ]]; then + + echo "Getting MD5Sums for RAW files..." + + #get md5sums for the files and print output + #Syntax: IMG_8217,IMG_8408,IMG_8544 ... (replace these file names just with md5sums and you get the idea) + INPUT_FILES_MD5SUM=$(echo -n $(printf '%s\n' $(md5sum "${@}") | sed '$!N;s/\n/ /' | awk -F ' ' '{print $2,$1}' | sed -e 's/^.*\///' | sort -n | awk -F ' ' '{print $2}' | tr '\n' ',' | sed 's/,*\r*$//')) + + echo "Comparing MD5Sums..." + + MAINCSV=$(find "${CSVFOLDER}" -maxdepth 1 -iname "${FILENAME}*${FILE_EXT}") + MAINCSV_COUNT=$(find "${CSVFOLDER}" -maxdepth 1 -iname "${FILENAME}*${FILE_EXT}" | wc -l) + + OTHER_CSV=$(find "${CSVFOLDER}" -maxdepth 1 -iname "*${FILE_EXT}") + OTHER_CSV_COUNT=$(find "${CSVFOLDER}" -maxdepth 1 -iname "*${FILE_EXT}" | wc -l) + + # Main CSV file + if [[ $COLUMNS_OK == true ]]; then + + COMPAREFILE_MD5SUM=$(echo -n $(awk -F ',' 'FNR> 1 {print $1,$2}' "${RAWDATA_TMP}" |sort -n | awk -F ' ' '{print $2}' | tr '\n' ',' | sed 's/,*\r*$//')) + + #if md5sums match OK, then... + if [[ "$INPUT_FILES_MD5SUM" == "$COMPAREFILE_MD5SUM" ]]; then + echo -e "MD5Sums match OK." + USEMAINCSV=true + else + echo -e "MD5Sums match not OK." + USEMAINCSV=false + fi + fi + + # Other CSV files, including variant of the CSV "file template" + if [[ ! -e "${RAWDATA_TMP}" ]] || [[ ! $OTHER_CSV_COUNT == 0 ]] || [[ $USEMAINCSV == false ]]; then + + # Check for CSV variants (which match the filename syntax) + if [[ $MAINCSV_COUNT -gt 0 ]]; then + + for m in $MAINCSV; do + echo "DEBUG: Do we get here 1?" + + COMPAREFILE_MD5SUM=$(echo -n $(awk -F ',' 'FNR> 1 {print $1,$2}' "${m}" |sort -n | awk -F ' ' '{print $2}' | tr '\n' ',' | sed 's/,*\r*$//')) + + if [[ "$INPUT_FILES_MD5SUM" == "$COMPAREFILE_MD5SUM" ]]; then + RAWDATA_TMP="${m}" + FILENAME=$(basename "${m}" | cut -f 1 -d '.') #We get the existing file name template and remove extension. + echo "DEBUG: Do we get here 2?" + USEMAINCSV=true + break + else + echo "DEBUG: Do we get here 3?" + USEMAINCSV=false + fi + done + fi + + # Check for other CSVs + if [[ $MAINCSV_COUNT -eq 0 ]] || [[ ! $OTHER_CSV_COUNT == 0 ]] && [[ $USEMAINCSV == false ]]; then + + for f in $OTHER_CSV; do + echo "DEBUG: Do we get here 4?" + COMPAREFILE_MD5SUM=$(echo -n $(awk -F ',' 'FNR> 1 {print $1,$2}' "${f}" |sort -n | awk -F ' ' '{print $2}' | tr '\n' ',' | sed 's/,*\r*$//')) + + if [[ "$INPUT_FILES_MD5SUM" == "$COMPAREFILE_MD5SUM" ]]; then + RAWDATA_TMP="${f}" + FILENAME=$(basename "${f}" | cut -f 1 -d '.') #We get the existing file name template and remove extension. + echo "DEBUG: Do we get here 5?" + USEOTHERCSV=true + break + else + echo "DEBUG: Do we get here 6?" + USEOTHERCSV=false + fi + done + fi + fi +fi + +if [[ $USEMAINCSV == false ]] && [[ $USEOTHERCSV == false ]]; then + + echo "DEBUG: Do we get here 7?" + x=1 + while [[ -e "${CSVFOLDER}/${FILENAME}-${x}${FILE_EXT}" ]]; do + let x++ + done + FILENAME="${FILENAME}-${x}" +fi + +echo -e "MD5Sums checked.\n" + + +if [[ $USEMAINCSV == true ]] || [[ $USEOTHERCSV == true ]]; then + echo -e "Found an existing CSV file with MD5Sums.\n" + +elif [[ $USEMAINCSV == true ]] && [[ $USEOTHERCSV == false ]]; then + echo -e "Using existing CSV with correct file template.\n" + +elif [[ $USEMAINCSV == true ]] && [[ $USEOTHERCSV == false ]]; then + echo -e "Using a custom named CSV file.\n" + +elif [[ $USEMAINCSV == false ]] || [[ $USEOTHERCSV == false ]]; then + echo -e "Creating a new CSV file.\n" +fi + +####################################################################### +#We need to redefine bash variables to overwrite the old values! +FILENAME2="${FILENAME}-temp" +FILENAME3="${FILENAME}-iso" + +RAWDATA_TMP="${CSVFOLDER}/${FILENAME}${FILE_EXT}" +RAWDATA_TMP2="/tmp/${FILENAME2}${FILE_EXT}" +RAWDATA_TMP3="/tmp/${FILENAME3}${FILE_EXT}" + +################# +#DEBUGGING +echo "We use file named $RAWDATA_TMP" + +if [[ $SEL3 == true ]]; then + echo "We use isofile named $RAWDATA_TMP2" + echo "We use tempfile named $RAWDATA_TMP3" +fi + +#echo +#exit +################# + +############################################################################################################################################## + +# KDIALOG PROCESSING WINDOW - BEGIN + +####PROGRESSBAR STUFF - BEGIN +LABELTEXT='Exporting statistics...' +numargs=$# # Number of all files +tics=100 # Percentage tics +inc=0 # Current file number +mltp=1000 # Percentage multiplier for bash + +if [[ ! -e "${RAWDATA_TMP}" ]]; then #If the file already exists, we don't want overwrite it. Instead, we skip these steps to speed up the process. + + dbusRef=$(kdialog --title "Metadata Extraction ($DIR_BASENAME: images $FIRST-$LAST)" --progressbar "$LABELTEXT" $tics) + qdbus $dbusRef showCancelButton true +####PROGRESSBAR STUFF - END + + while [[ $# -gt 0 ]] && [[ $(qdbus $dbusRef wasCancelled) == "false" ]]; do + + i="${1}" + +############################################## +# 1 COLUMN + # ENABLE THIS IF STATEMENT ONLY IF FILE NAMES CONTAINING 'IMG_' ARE ONLY ACCEPTED + + #if [[ ! $(echo $(basename "${1}" | cut -f 1 -d '.')) == *"IMG_"* ]]; then + # echo $(basename "${1}" | cut -f 1 -d '.') + # ERRFILE=1 #PRINT INVALID INPUT AS THE LAST COLUMN DUE TO DATE/TIME COLUMNS! SEE BELOW! + #else + echo $(basename "${i}" | cut -f 1 -d '.') #| sed -e 's/IMG_//g') #echo ${i##*/} | sed -e 's/.CR2//g' -e 's/.DNG//g') + # ERRFILE=0 + #fi + +############################################## +# 2 COLUMN + #Write md5sum of a file for checking purposes! + md5sum "${i}" | awk -F ' ' '{print $1}' + +############################################## +# 3 COLUMN + if [[ $(exiftool "${i}" |grep --max-count=1 "Camera Temperature" | sed -e 's/[^0-9]*//g' | wc -l) -eq 1 ]]; then + exiftool "${i}" |grep --max-count=1 "Camera Temperature" | sed -e 's/[^0-9]*//g' + else + echo "errtag" + fi + +############################################## +# 4 COLUMN + # ISO Speed setting (yeah, we get it from "Recommended Exposure Index" tag. + if [[ $(exiftool "${i}" | grep -v "Sensitivity" | grep --max-count=1 "Recommended Exposure Index" | sed 's/[^0-9]*//g' | wc -l) -eq 1 ]]; then + exiftool "${i}" | grep -v "Sensitivity" | grep --max-count=1 "Recommended Exposure Index" | sed 's/[^0-9]*//g' + else + echo "errtag" + fi + +############################################## +# 5 COLUMN + if [[ $(exiftool "${i}" |grep --max-count=1 "Exposure Time" | sed -e 's/[A-Za-z]*//g' -e 's/.*: //g' | wc -l) -eq 1 ]]; then + exiftool "${i}" |grep --max-count=1 "Exposure Time" | sed -e 's/[A-Za-z]*//g' -e 's/.*: //g' + else + echo "errtag" + fi + +############################################## +# 6 COLUMN + if [[ $(exiftool "${i}" |grep --max-count=1 "Target Exposure Time" | sed -e 's/[A-Za-z]*//g' -e 's/.*: //g' | wc -l) -eq 1 ]]; then + exiftool "${i}" |grep --max-count=1 "Target Exposure Time" | sed -e 's/[A-Za-z]*//g' -e 's/.*: //g' + else + echo "errtag" + fi + +############################################## +# 7 COLUMN + if [[ $(exiftool "${i}" |grep --max-count=1 "Exposure Compensation" | sed -e 's/[A-Za-z]*//g' -e 's/.*: //g' | wc -l) -eq 1 ]]; then + exiftool "${i}" |grep --max-count=1 "Exposure Compensation" | sed -e 's/[A-Za-z]*//g' -e 's/.*: //g' + else + echo "errtag" + fi + +############################################## +# 8 COLUMN + if [[ $(exiftool "${i}" |grep --max-count=1 "Aperture Value" | sed -e 's/[A-Za-z]*//g' -e 's/.*: //g' | wc -l) -eq 1 ]]; then + exiftool "${i}" |grep --max-count=1 "Aperture Value" | sed -e 's/[A-Za-z]*//g' -e 's/.*: //g' + else + echo "errtag" + fi + +############################################## +# 9 COLUMN + if [[ $(exiftool "${i}" |grep --max-count=1 "Target Aperture" | sed -e 's/[A-Za-z]*//g' -e 's/.*: //g' | wc -l) -eq 1 ]]; then + exiftool "${i}" |grep --max-count=1 "Target Aperture" | sed -e 's/[A-Za-z]*//g' -e 's/.*: //g' + else + echo "errtag" + fi + +############################################## +# 10 COLUMN +# Average histogram value for image (brightness etc.) +# For documentation, see http://netpbm.sourceforge.net/doc/pgmhist.html +# we need to convert the image into grayscale with dcraw -d option +# dcraw "manual" is found here: http://www.inweb.ch/foto/dcrawhelp.txt + + if [[ $(dcraw -d -4 -j -c "${i}" | pgmhist -median | wc -l) -eq 1 ]]; then + dcraw -d -4 -j -c "${i}" | pgmhist -median | sed 's/[^0-9]*//g' + else + echo "errtag" + fi + +############################################## +# 11 COLUMN + if [[ $(exiftool "${i}" |grep --max-count=1 "Focal Length" | sed -e 's/[A-Za-z]*//g' -e 's/.*: //g' -e 's/ //g' | wc -l) -eq 1 ]]; then + exiftool "${i}" |grep --max-count=1 "Focal Length" | sed -e 's/[A-Za-z]*//g' -e 's/.*: //g' -e 's/ //g' #sed 's/ mm//g' + else + echo "errtag" + fi + +############################################## +# 12 COLUMN + if [[ $(exiftool "${i}" |grep --max-count=1 "Hyperfocal Distance" | sed -e 's/.*: //g' -e 's/ m//g' | wc -l) -eq 1 ]]; then + exiftool "${i}" |grep --max-count=1 "Hyperfocal Distance" | sed -e 's/.*: //g' -e 's/ m//g' + else + echo "errtag" + fi + +############################################## +# 13 COLUMN + if [[ $(exiftool "${i}" |grep --max-count=1 "Focus Distance Upper" | sed -e 's/.*: //g' -e 's/ m//g' | wc -l) -eq 1 ]]; then + exiftool "${i}" |grep --max-count=1 "Focus Distance Upper" | sed -e 's/.*: //g' -e 's/ m//g' + else + echo "errtag" + fi + +############################################## +# 14 COLUMN + if [[ $(exiftool "${i}" |grep --max-count=1 "Focus Distance Lower" | sed -e 's/.*: //g' -e 's/ m//g' | wc -l) -eq 1 ]]; then + exiftool "${i}" |grep --max-count=1 "Focus Distance Lower" | sed -e 's/.*: //g' -e 's/ m//g' + else + echo "errtag" + fi + +############################################## +# 15 COLUMN + if [[ $(exiftool "${i}" |grep --max-count=1 "Depth Of Field" | sed -e 's/.*: //g' -e 's/ m//g' | wc -l) -eq 1 ]]; then + exiftool "${i}" |grep --max-count=1 "Depth Of Field" | sed -e 's/.*: //g' -e 's/ m//g' + else + echo "errtag" + fi + +############################################## +# 16 COLUMN + if [[ $(exiftool "${i}" |grep --max-count=1 "Camera Model Name" | sed 's/.*: //g' | wc -l) -eq 1 ]]; then + exiftool "${i}" |grep --max-count=1 "Camera Model Name" | sed 's/.*: //g' + else + echo "errtag" + fi + +############################################## +# 17 COLUMN + if [[ $(exiftool "${i}" |grep --max-count=1 "Lens Type" | sed 's/.*: //g' | wc -l) -eq 1 ]]; then + exiftool "${i}" |grep --max-count=1 "Lens Type" | sed 's/.*: //g' + else + echo "errtag" + fi + +############################################## +# 18 COLUMN + if [[ $(exiftool "${i}" |grep --max-count=1 "Focus Mode" | sed 's/.*: //g' | wc -l) -eq 1 ]]; then + exiftool "${i}" |grep --max-count=1 "Focus Mode" | sed 's/.*: //g' + else + echo "errtag" + fi + +############################################## +# 19 COLUMN + if [[ $(exiftool "${i}" |grep --max-count=1 "Shooting Mode" | sed 's/.*: //g' | wc -l) -eq 1 ]]; then + exiftool "${i}" |grep --max-count=1 "Shooting Mode" | sed 's/.*: //g' + else + echo "errtag" + fi + +############################################## +# 20 COLUMN + if [[ $(exiftool "${i}" |grep --max-count=1 "Live View Shooting" | sed 's/.*: //g' | wc -l) -eq 1 ]]; then + exiftool "${i}" |grep --max-count=1 "Live View Shooting" | sed 's/.*: //g' + else + echo "errtag" + fi + +############################################## +# 21 COLUMN + if [[ $(exiftool "${i}" |grep --max-count=1 "Camera Orientation" | sed 's/.*: //g' | wc -l) -eq 1 ]]; then + exiftool "${i}" |grep --max-count=1 "Camera Orientation" | sed 's/.*: //g' + else + echo "errtag" + fi + +############################################## +# 21 COLUMN +# Subject Tags + + if [ $(exiftool "${i}" |grep --max-count=1 "Subject" | sed -e 's/.*: //g' | wc -l) == 0 ]; then + + # If Subject tag is empty, get input file filetype (CR2 or cr2 // DNG or dng) + if [[ $(echo $(basename "${i}" | cut -f 2 -d '.' | sed '/^\s*$/d')) == "CR2" ]] || [[ $(echo $(basename "${i}" | cut -f 2 -d '.' | sed '/^\s*$/d')) == "cr2" ]]; then + echo "Single ISO CR2" + + elif [[ $(echo $(basename "${i}" | cut -f 2 -d '.' | sed '/^\s*$/d')) == "DNG" ]] || [[ $(echo $(basename "${i}" | cut -f 2 -d '.' | sed '/^\s*$/d')) == "dng" ]]; then + echo "Single ISO DNG" + fi + + #If we have a real Subject tag, extract info from it + else + exiftool "${i}" |grep --max-count=1 "Subject" | sed -e 's/.*: //g' + fi + +############################################## +# 23 COLUMN + if [[ $(exiftool "${i}" |grep --max-count=1 "Date/Time Original" | sed -e 's/.*: //g' | cut -d' ' -f1 | awk -F ":" '{print $3, $2, $1}' | sed -e 's/ /\//g' | wc -l) -eq 1 ]]; then + + exiftool "${i}" |grep --max-count=1 "Date/Time Original" | sed -e 's/.*: //g' | cut -d' ' -f1 | awk -F ":" '{print $3, $2, $1}' | sed -e 's/ /\//g' + else + echo "errtag" + fi + +############################################## +# 24 COLUMN + if [[ $(exiftool "${i}" |grep --max-count=1 "Date/Time Original" | sed -e 's/.*: //g' | cut -d' ' -f2 | wc -l) -eq 1 ]]; then + + exiftool "${i}" |grep --max-count=1 "Date/Time Original" | sed -e 's/.*: //g' | cut -d' ' -f2 + else + echo "errtag" + fi + +############################################## +# ENABLE THIS FOR CHECKING FILE NAMES. IF ENABLED, ALL FILES MUST CONTAIN 'IMG_' STRING OR OTHERWISE, THEY ARE EXCLUDED FROM THE STATISTICS! + #Write this line/column only, if an invalid file name has been detected +# if [[ "$ERRFILE" -eq 1 ]]; then +# echo "errname" +# fi + +############################################## + + echo "newline" #this is written just as a dummy separator for each processed files for further line separation done below. + +############################################## + + ####PROGRESSBAR STUFF - BEGIN + # This section is increasing values seen in the kdialog processing window. + + let inc++ + + #Percentage needs to be calculated like this due to bash rounding limitations... + PERCENT_VALUE=$((($mltp*$tics)/(200*$numargs/$inc % 2 + $mltp*$numargs/$inc))) + + qdbus $dbusRef Set "" "value" $PERCENT_VALUE; + qdbus $dbusRef setLabelText "$LABELTEXT ($inc/$numargs)"; + + ####PROGRESSBAR STUFF - END + + shift + +############################################## + + # Sort output: replace newlines with commas, remove more commas, replace 'newline' with a new line, trim the first and the last commas of any line. Sort lines by Date & Time (23th & 24th column) and write output + done | tr '\n' ',' | sed -e 's/,[^,]*$//' -e 's/newline/\n/g' | sed -e 's/^,//g' -e 's/\(.*\),/\1/' | sort -t ',' -n -k23 -k24 | sed 's/inf/∞/g' > "${RAWDATA_TMP}" #| sed 's/newline/\n/g' | sort -u + +############################################## + +#Close processing window if cancelled event has been triggered. + + ####PROGRESSBAR STUFF - BEGIN + # If the process was cancelled, remove tmp file and exit the script. + if [[ ! $(qdbus $dbusRef wasCancelled) == "false" ]]; then + rm "${RAWDATA_TMP}" #We can delete the file because its existence has been checked before the processing window has been opened. Thus we don't get here, if the file already exists. + exit + fi + ####PROGRESSBAR STUFF - END +########################################### + + #Add correct titles to the first row in RAWDATA_TMP file: + sed -i '1s/^/Image File,File MD5Sum,Camera Temperature,ISO,Shutter Speed,Target Exposure,Exposure Compensation,Aperture,Target Aperture,Histogram Median,Focal Length,Hyperfocal Distance,Upper Focus Distance,Lower Focus Distance,Depth Of Field,Camera Model,Lens Model,Focus Mode,Exposure Mode,Live View,Camera Orientation,ISO Type,Date,Time\n/' "${RAWDATA_TMP}" + + #Close processing window if not cancelled and processing finished. + ####PROGRESSBAR STUFF - BEGIN + qdbus $dbusRef close + ####PROGRESSBAR STUFF - END + + # SEL1 = "Apertures, Exposures & ISOs" true/false + # SEL2 = "Focal Lengths & Lenses" true/false + # SEL3 = "Temperatures & ISOs" true/false + # SEL4 = "Shooting & Focus Modes" true/false + # SEL5 = "Export Only (CSV)" true/false + + if [[ $SEL5 == true ]]; then + kdialog --msgbox "EXIF data exported successfully"; + exit + fi + +elif [[ -e "${RAWDATA_TMP}" ]] && [[ $SEL5 == true ]]; then + kdialog --msgbox "EXIF data exported already.\n\nFile:\n\n${RAWDATA_TMP}"; + exit +fi + +#KDIALOG PROCESSING WINDOW - END + +############################################## + +# Check RAWDATA_TMP for bad line outputs + + # 1) BADFILES: Open written (or existing) CSV file + # 2) BADFILES: List all lines matching pattern "errname" or "errtag" + # 3) BADFILES: Write output as a single line, using comma mark to separate the written output (file names). Remove the last extra comma. + +BADFILES=$(cat "${RAWDATA_TMP}" | sed -ne '/errname/p' -ne '/errtag/p' | sed 's/,.*$//') +BADFILES_COUNT=$(cat "${RAWDATA_TMP}" | sed -ne '/errname/p' -ne '/errtag/p' | sed 's/,.*$//' | wc -l) + +#Count lines found in the output of BADFILES. If not zero (e.g. bad strings found), then... +if [[ $BADFILES_COUNT != 0 ]]; then + + cat "${RAWDATA_TMP}" | sed -e '/errname/d' -e '/errtag/d' > "/tmp/${FILENAME}-errtags${FILE_EXT}" + RAWDATA_TMP_ERR="/tmp/${FILENAME}-errtags${FILE_EXT}" #We don't want to overwrite the original file. + + if [[ $(cat "${RAWDATA_TMP_ERR}" | wc -l) == 1 ]]; then #If not any valid output image files. Minimum count of lines is 2. + kdialog --error "Could not process any input file:\n\n$BADFILES\n\nThis can be due to missing EXIF data such as Temperature, ISO, Date or Time.\n\nPlease check CSV file (${FILENAME}${FILE_EXT}) contents to study the problem.\n\nExiting."; + rm "${RAWDATA_TMP_ERR}" + exit + elif [[ $(cat "${RAWDATA_TMP_ERR}" | wc -l) -le 2 ]]; then #if we have just a single file here. Minimum count of lines is 3. + kdialog --error "Could not process a valid number of input files. Minimum count of valid files is 2.\n\nFiles that could not be processed:\n\n$BADFILES\n\nThis can be due to missing EXIF data such as Temperature, ISO, Date or Time.\n\nPlease check CSV file (${FILENAME}${FILE_EXT}) contents to study the problem.\n\nExiting." + rm "${RAWDATA_TMP_ERR}" + exit + else + mv "/tmp/${FILENAME}-errtags${FILE_EXT}" "${CSVFOLDER}/${FILENAME}-errtags${FILE_EXT}" + RAWDATA_TMP="${CSVFOLDER}/${FILENAME}-errtags${FILE_EXT}" + kdialog --msgbox "Could not process files:\n\n$BADFILES\n\nThis can be due to missing EXIF data such as Temperature, ISO, Date or Time.\n\nPlease exclude these files or check CSV file (${FILENAME}${FILE_EXT}) contents to study the problem.\n\nNew CSV file written as (bad files excluded):\n${RAWDATA_TMP}"; + fi +fi + +###################################################################################### + +FILELIST=$(echo -n $(awk -F ',' 'FNR> 1 {print $1}' "${RAWDATA_TMP}" |sort -n |tr ' ' '\n' | sort -n | tr '\n' ',' | sed 's/,*\r*$//')) + +#Total count of accepted pictures, used for further data representation in gnuplot. We reduce it by 1 due to file header (column titles are not counted): +ACCEPTED_TOTAL=$(echo -n $(($(cat "${RAWDATA_TMP}" | wc -l) - 1))) + +############################################################################################################################################## +############################################################################################################################################## +############################################################################################################################################## + +####GNUPLOT STUFF - BEGIN + +GNUPLOT_MAINWINDOW_TITLE=$(echo "$DIR_BASENAME ($ACCEPTED_TOTAL images, $FILENAME)") + +########################################################### +# GNUPLOT TIME VALUES + +#PLOT 1 +# Should we use time values in the first plot? If too many images, basically rendered unreadable +# Rotate x labels if there are too many of them + +if [[ $ACCEPTED_TOTAL -lt 10 ]]; then #Do not rotate x labels, if we have less than 10 images selected + X_ROTATELABELS=$(echo -n "") + if [[ $ACCEPTED_TOTAL -le 6 ]]; then #Time values are only if max 6 images selected + X2_TIMESTRINGS=$(echo -n "set x2tics offset 0,-0.5") + else + X2_TIMESTRINGS=$(echo -n "unset x2tics") + fi +else + X_ROTATELABELS=$(echo -n "set xtics rotate 90") +fi + +############################################################ + +#IMAGE COUNT/UNIT SCALES FOR GNUPLOT PLOTS 2 & 3 + +if [[ $ACCEPTED_TOTAL -le 10 ]]; then + SCALE=1 +elif [[ $ACCEPTED_TOTAL -gt 10 ]] && [[ $ACCEPTED_TOTAL -le 20 ]]; then + SCALE=2 +elif [[ $ACCEPTED_TOTAL -gt 20 ]] && [[ $ACCEPTED_TOTAL -le 40 ]]; then + SCALE=4 +elif [[ $ACCEPTED_TOTAL -gt 40 ]] && [[ $ACCEPTED_TOTAL -le 60 ]]; then + SCALE=6 +elif [[ $ACCEPTED_TOTAL -gt 60 ]] && [[ $ACCEPTED_TOTAL -le 80 ]]; then + SCALE=8 +elif [[ $ACCEPTED_TOTAL -gt 80 ]] && [[ $ACCEPTED_TOTAL -le 200 ]]; then + SCALE=10 +elif [[ $ACCEPTED_TOTAL -gt 200 ]] && [[ $ACCEPTED_TOTAL -le 400 ]]; then + SCALE=20 +elif [[ $ACCEPTED_TOTAL -ge 400 ]]; then + SCALE=40 +fi + +############################################################################################################################################## +############################################################################################################################################## +############################################################################################################################################## + +# ISO VALUES + +#Do the following stuff only, if we have checked for any ISO related stuff in the kdialog selection. +if [[ $SEL1 == true ]] || [[ $SEL3 == true ]]; then + +#ISO min max values + +# 1) Use awk to print field 3 from RAWDATA_TMP. Ignore the first row with FNR> 1 option. +# 2) awk prints equivalent numbers as output. Merge them with "|sort -n" pipe. sort prints numbers starting from the smallest (first line) and ending to the greatest (last line) +# 3) Strip the output, either first line (head -1) or the last one (tail -1). + + ISO_MIN_VALUE=$(echo -n $(awk -F ',' 'FNR> 1 {print $4}' "${RAWDATA_TMP}" | sort -n | head -1)) + ISO_MAX_VALUE=$(echo -n $(awk -F ',' 'FNR> 1 {print $4}' "${RAWDATA_TMP}" | sort -n | tail -1)) + +#################################################################################################################### + +# ISO VALUES GENERATING RAWDATA_TMP2 + +#Get percentages for ISO values usage + +# OUTPUT template for RAWDATA_TMP3 is as follows: + +# ,, + +# Explanation for the following command: + +# 1) Use awk to print field 3 from RAWDATA_TMP. Ignore the first row with FNR> 1 option. +# 2) awk prints equivalent numbers as output. Count and merge them with "|sort -n | uniq -c" pipe +# 3) Output results leading white spaces. For each line, delete them with sed. +# 4) use awk as pipe (awk starting with '{b[$2]=$1;sum=sum ...) to calculate percentage for the first column. First column has count number for each ISO value ("how many times ISO XX is used"). ISOs are defined in column 2. Print the output to a new column 3. +# 5) In step 4, the output has too many decimals. As the output of this step is written to column 3, we use another awk pipe to strip too many decimals of the current column 3. To keep two first decimals, we use %.2f option. Print column 1 ($1) and 2 ($2) as they are, respectively. Add % mark and start a new line (\n) after each printf function. +# 6) Replace spaces with commas for the final output, and write the final output to RAWDATA_TMP3. + + awk -F ',' 'FNR> 1 {print $4}' "${RAWDATA_TMP}" |sort -n | uniq -c | sed "s/^[ \t]*//" | awk '{b[$2]=$1;sum=sum+$1} END{for (i in b) print b[i],i,(b[i]/sum)*100}' | awk '{printf "%.0f %.0f %.2f'%'\n", $1,$2,$3}' | tr ' ' ',' > "${RAWDATA_TMP2}" + +#################################################################################################################### + +# ISO VALUES - MINIMUM, MAXIMUM, LEAST USED, MOST USED AND AVERAGE + +#What is the maximum number of matches for a single ISO value? + MAX_MATCH_FOR_ISO=$(echo -n $(awk -F ',' '{print $1}' "${RAWDATA_TMP2}" | sort -n | tail -1)) + +#We store current min/max ISOvalues to a string variables + WHATIS_REAL_MAX_ISO=$(echo -en "Max: $ISO_MAX_VALUE") # Returns column 3 value of RAWDATA_TMP E.G. 3200, based on max column 3 value of RAWDATA_TMP + WHATIS_REAL_MIN_ISO=$(echo -en "Min: $ISO_MIN_VALUE") # Returns column 3 value of RAWDATA_TMP E.G. 200, based on min column 3 value of RAWDATA_TMP + +#Format: (1*400)+(1*1600)+(2*3200) ... + ISO_DIVIDEND=$(echo -n $(($(awk -F ',' '{print "("$1,$2")"}' "${RAWDATA_TMP2}" | sort -n | sed -e 's/ /*/g' | tr '\n' '+' | sed 's/+[^+]*$//')))) + +#Just a basic average calculation + ISO_AVERAGE=$(echo -e $(awk 'BEGIN {print "'"$ISO_DIVIDEND"'"/"'"$ACCEPTED_TOTAL"'"}' | awk '{printf "%.0f", $1}')) + +########################################################## + +# ISO VALUES - CHECK FOR MIN AND MAX VALUES + +# 1) Get awk output of file RAWDATA_TMP3, separator for columns is comma mark, get column 3 ($3) +# 2) Sort percentage values from lowest to greatest, starting from the lowest +# 3) Get the match count for each percentage value (column 3 value) with 'uniq -c' +# 4) Trim all leading white spaces for each printed line +# 5) We have now two columns, separated by space. Get the first column with awk pipe, use space as a column separator, and print column 1 ($1) +# 6) Get the first line. Output represents the number of matches for listed percentage. We check if it's not 1 in the following if statement. + +# The whole idea is that we can't give a true statement for "What is the least/most used ISO value" if multiple ISO values equal same percentage for usage + + MOSTUSED_ISO_CHECK=$(echo -n $(awk -F ',' '{print $3}' "${RAWDATA_TMP2}" | sort -n | uniq -c | sed "s/^[ \t]*//" | awk -F ' ' '{print $1}' | tail -1)) + LEASTUSED_ISO_CHECK=$(echo -n $(awk -F ',' '{print $3}' "${RAWDATA_TMP2}" | sort -n | uniq -c | sed "s/^[ \t]*//" | awk -F ' ' '{print $1}' | head -1)) + +#The following gives a correct value ONLY IF there are unique values for EACH ISOs. Otherwise, the output is not as expected. That's why we need to check the values of MOST/LEASTUSED_ISO_CHECK first. + MOSTUSED_ISO=$(echo -n $(awk -F ',' '{print $3,$2}' "${RAWDATA_TMP2}" | sort -n | awk -F ' ' '{print $2}' | tail -1)) + LEASTUSED_ISO=$(echo -n $(awk -F ',' '{print $3,$2}' "${RAWDATA_TMP2}" | sort -n | awk -F ' ' '{print $2}' | head -1)) + +########################################################## + +#In addition, we consider that minimum of 10 pictures must be accepted as input. Otherwise, user can read this info pretty easily just checking the gnuplot graphs. + + if [[ "$LEASTUSED_ISO_CHECK" -ne 1 ]]; then #If more than one, then... + WHATIS_LEASTUSED_ISO=$(echo -n "") #Output string, nothing to say. + elif [[ "$LEASTUSED_ISO_CHECK" -eq 1 ]]; then #Else if it's one, then... + if [[ "$ACCEPTED_TOTAL" -gt 10 ]]; then #...we check the number of pictures. If it's greater than 10, then print the following string. + WHATIS_LEASTUSED_ISO=$(echo -n ", Least used: $LEASTUSED_ISO") #Returns column 2 value of RAWDATA_TMP3 E.G. 400, based on max column 3 value of RAWDATA_TMP3 + elif [[ "$ACCEPTED_TOTAL" -le 10 ]]; then #...we check the number of pictures. If it's equal or less than 10, we print nothing. + WHATIS_LEASTUSED_ISO=$(echo -n "") #Output string, nothing to say + fi + fi + + if [[ "$MOSTUSED_ISO_CHECK" -ne 1 ]]; then #If more than one, then... + WHATIS_MOSTUSED_ISO=$(echo -n "") #Output string, nothing to say. + elif [[ "$MOSTUSED_ISO_CHECK" -eq 1 ]]; then #Else if it's one, then... + if [[ "$ACCEPTED_TOTAL" -gt 10 ]]; then #...we check the number of pictures. If it's greater than 10, then print the following string. + WHATIS_MOSTUSED_ISO=$(echo -n ", Most used: $MOSTUSED_ISO") #Returns column 2 value of RAWDATA_TMP3 E.G. 400, based on max column 3 value of RAWDATA_TMP3 + elif [[ "$ACCEPTED_TOTAL" -le 10 ]]; then #...we check the number of pictures. If it's equal or less than 10, we print nothing. + WHATIS_MOSTUSED_ISO=$(echo -n "") #Output string, nothing to say + fi + fi + +# Max ISO string: $WHATIS_REAL_MAX_ISO +# Min ISO string: $WHATIS_REAL_MIN_ISO +# Least used ISO string: $WHATIS_LEASTUSED_ISO +# Most used ISO string: $WHATIS_MOSTUSED_ISO + +########################################################### + +# ISO VALUES - SHIFT ISO RANGE VALUES FOR GNUPLOT + +# We shift down minimum ISO values to get a proper scale for gnuplot. Use "Less than" integer comparison because there can be ISO values such as 160, 250... + +#DO NOT CHANGE THE CHECK (ELIF EXECUTION) ORDER!! + + if [[ "$ISO_MIN_VALUE" -le 100 ]]; then #Less or equal than... + ISO_MIN_VALUE_GNU=0 #Just scaling down, not a true ISO value + elif [[ "$ISO_MIN_VALUE" -le 200 ]]; then + ISO_MIN_VALUE_GNU=100 + elif [[ "$ISO_MIN_VALUE" -le 400 ]]; then + ISO_MIN_VALUE_GNU=200 + elif [[ "$ISO_MIN_VALUE" -le 800 ]]; then + ISO_MIN_VALUE_GNU=400 + elif [[ "$ISO_MIN_VALUE" -le 1600 ]]; then + ISO_MIN_VALUE_GNU=800 + elif [[ "$ISO_MIN_VALUE" -le 3200 ]]; then + ISO_MIN_VALUE_GNU=1600 + elif [[ "$ISO_MIN_VALUE" -le 6400 ]]; then + ISO_MIN_VALUE_GNU=3200 + elif [[ "$ISO_MIN_VALUE" -le 8000 ]]; then + ISO_MIN_VALUE_GNU=6400 + fi + + if [[ "$ISO_MAX_VALUE" -ge 8000 ]]; then #Greater or equal than... + ISO_MAX_VALUE_GNU=12800 + elif [[ "$ISO_MAX_VALUE" -ge 6400 ]]; then + ISO_MAX_VALUE_GNU=8000 + elif [[ "$ISO_MAX_VALUE" -ge 3200 ]]; then + ISO_MAX_VALUE_GNU=6400 + elif [[ "$ISO_MAX_VALUE" -ge 1600 ]]; then + ISO_MAX_VALUE_GNU=3200 + elif [[ "$ISO_MAX_VALUE" -ge 800 ]]; then + ISO_MAX_VALUE_GNU=1600 + elif [[ "$ISO_MAX_VALUE" -ge 400 ]]; then + ISO_MAX_VALUE_GNU=800 + elif [[ "$ISO_MAX_VALUE" -ge 200 ]]; then + ISO_MAX_VALUE_GNU=400 + elif [[ "$ISO_MAX_VALUE" -ge 100 ]]; then + ISO_MAX_VALUE_GNU=200 + fi + +########################################################### + +#Export all used ISO values + GET_ISO_VALUES=$(echo -n $(awk -F ',' 'FNR> 1 {print $4}' "${RAWDATA_TMP}" | awk '!seen[$0]++' |sort -n | tr '\n' ',' | sed -e 's/,[^,]*$//')) + + ISO_TICSRANGE=$(echo -n $ISO_MIN_VALUE_GNU,$GET_ISO_VALUES,$ISO_MAX_VALUE_GNU) + +########################################################### + +fi + +############################################################################################################################################## +############################################################################################################################################## +############################################################################################################################################## + +# TEMPERATURE VALUES + +#Do the following stuff only, if we have checked for any ISO related stuff in the kdialog selection. +if [[ $SEL3 == true ]]; then + +#################################################################################################################### + +#RAWDATA_TMP2 +#Get percentages for temperature values + +# OUTPUT template for RAWDATA_TMP2 is as follows: + +# ,, + +# Explanation for the following command: + +# 1) Use awk to print field 2 from RAWDATA_TMP. Ignore the first row with FNR> 1 option. +# 2) awk prints equivalent numbers as output. Count and merge them with "|sort -n | uniq -c" pipe +# 3) Output results leading white spaces. For each line, delete them with sed. +# 4) use awk as pipe (awk starting with '{b[$2]=$1;sum=sum ...) to calculate percentage for the first column. First column has count number for each temperature value ("how many matches for XX temperature"). Temperature values are defined in column 2. Print the output to a new column 3. +# 5) In step 4, the output has too many decimals. As the output of this step is written to column 3, we use another awk pipe to strip too many decimals of the current column 3. To keep two first decimals, we use %.2f option. Print column 1 ($1) and 2 ($2) as they are, respectively. Add % mark and start a new line (\n) after each printf function. +# 6) Replace spaces with commas for the final output, and write the final output to RAWDATA_TMP2. + + awk -F ',' 'FNR> 1 {print $3}' "${RAWDATA_TMP}" |sort -n | uniq -c | sed "s/^[ \t]*//" | awk '{b[$2]=$1;sum=sum+$1} END{for (i in b) print b[i],i,(b[i]/sum)*100}' | awk '{printf "%.0f %.0f %.2f'%'\n", $1,$2,$3}' | tr ' ' ',' > "${RAWDATA_TMP3}" + +#################################################################################################################### + +#Temperature min max values (actual values from the file) + TEMP_MIN=$(echo -n $(awk -F ',' 'FNR> 1 {print $3}' "${RAWDATA_TMP}" | sort -n | head -1)) #Min Temp string + TEMP_MAX=$(echo -n $(awk -F ',' 'FNR> 1 {print $3}' "${RAWDATA_TMP}" | sort -n | tail -1)) #Max Temp string + +#Format: (1*31)+(1*38)+(2*39) ... + TEMP_DIVIDEND=$(echo -n $(($(awk -F ',' '{print "("$1,$2")"}' "${RAWDATA_TMP3}" | sort -n | sed -e 's/ /*/g' | tr '\n' '+' | sed 's/+[^+]*$//')))) + +#Just a basic average calculation + TEMP_AVERAGE=$(echo -e $(awk 'BEGIN {print "'"$TEMP_DIVIDEND"'"/"'"$ACCEPTED_TOTAL"'"}' | awk '{printf "%.2f", $1}')) + +############################################## + +#What is the maximum number of matches for a single temperature? + MAX_MATCH_FOR_TEMP=$(echo -n $(awk -F ',' '{print $1}' "${RAWDATA_TMP3}" | sort -n | tail -1)) + +#Round temperature scale + TEMP_MULTP=2 #Multiplier for temperature scale for plot 1. (scale only!) + +#TEMP_INCREMENT=2 #Temperature increment steps. For example, with value of 2, we get ...0, 2...10, 12, 14, 16...24... etc. + +# We set minimum temperature to - 2, rounding down +UNROUNDED_MIN=$(echo -n $(($TEMP_MIN - $TEMP_MULTP))) + +# BASE LAYOUT FOR THE FOLLOWING AWK STUFF: +# awk '{i=int($0/4);print((i==$0||$0>0)?i:i-1)*4}' +# https://stackoverflow.com/questions/33085008/bash-round-to-nearest-multiple-of-4 + MINVALUE_TEMP=$(echo -n $UNROUNDED_MIN | awk '{i=int("'"$UNROUNDED_MIN"'"/"'"$TEMP_MULTP"'");print((i=="'"$UNROUNDED_MIN"'"||"'"$UNROUNDED_MIN"'">0)?i:i-1)*"'"$TEMP_MULTP"'"}') + +# We set maximum temperature to + 2, rounding up + UNROUNDED_MAX=$(echo -n $(($TEMP_MAX + $TEMP_MULTP))) + +# BASE LAYOUT FOR THE FOLLOWING AWK STUFF: +# awk '{print$0+(n-$0%n)%n}' +# https://stackoverflow.com/questions/33085008/bash-round-to-nearest-multiple-of-4 + MAXVALUE_TEMP=$(echo -n $UNROUNDED_MAX | awk '{print"'"$UNROUNDED_MAX"'"+("'"$TEMP_MULTP"'"-"'"$UNROUNDED_MAX"'"%"'"$TEMP_MULTP"'")%"'"$TEMP_MULTP"'"}') + +fi + +############################################################################################################################################## +############################################################################################################################################## +############################################################################################################################################## + +# SELECTION 3 - TEMPERATURES & ISOS + +######################################################################################## +# PLOT 1 (Images & Temperatures & ISOS) + +if [[ $SEL3 == true ]]; then + +#GNUPLOT, ACTUAL PROGRAM EXECUTION STARTS HERE: + +gnuplot < 1 {print $1}' "${RAWDATA_TMP}" |sort -n |tr ' ' '\n' | sort -n | tr '\n' ',' | sed 's/,*\r*$//')) +#DEPRECATED + +# This syntax is used for md5sums check as well... + +####################################################################### + +#(For temperatures?) Deprecated: +#awk -F ',' 'FNR> 1 {print $2}' "${RAWDATA_TMP}" |sort -n | uniq -c | sed "s/^[ \t]*//" | tr ' ' ',' > "${RAWDATA_TMP2}" + +#Add some ISO and temperature statistics + +#paste <(echo "${ISO_ALL_COUNT}") <(echo "${TEMP_ALL_COUNT}") -d , > "${RAWDATA_TMP2}" + +#RAWDATA 2 FILE DATA ORDER AS FOLLOWS: + +#TEMPERATURE_COUNTS,TEMPERATURE_VALUE,ISO_USAGE_COUNTS,ISO_SPEED_VALUES + +# |awk '{print "("$0")"}' --brackets + +#ARG1=$1 +#ARG2=$2 +#ARG3=$3 +#ARG4=$4 +#ARG5=$5 +#ARG6=$6 + +#gnuplot --persist -e "TITLE='${GNUPLOT_TITLE}'; RAWFILE='${RAWDATA_TMP}'; WINDOWTITLE='${GNUPLOT_MAINWINDOW_TITLE}'; ISO_MIN='${ISO_MIN_VALUE}'; ISO_MAX='${ISO_MAX_VALUE}'; ISO_VALUES='${GET_ISO_VALUES}';" $GNUPLOT_SCRIPT #ARG3='${ARG3}'; ARG4='${ARG4}'; ARG5='${ARG5}'; ARG6='${ARG6}'" $GNUPLOT_FILE + +# Max ISO string: $WHATIS_REAL_MAX_ISO +# Min ISO string: $WHATIS_REAL_MIN_ISO +# Least used ISO string: $WHATIS_LEASTUSED_ISO +# Most used ISO string: $WHATIS_MOSTUSED_ISO + diff --git a/4_scripts/imagetools_02_dualiso.sh b/4_scripts/imagetools_02_dualiso.sh new file mode 100644 index 0000000..450e9f6 --- /dev/null +++ b/4_scripts/imagetools_02_dualiso.sh @@ -0,0 +1,173 @@ +#!/bin/bash + +# Batch convert multiple Magic Lantern dual ISO image files on Linux +# Copyright (C) 2017 Pekka Helenius +# +# 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 the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +############################################### + +# NOTE: This script REQUIRES a patched cr2hdr tool with '--dry-run' parameter support!! +# Required patch file is provided in the same repository with this script + +#Brackets and quotation marks in variables prevent errors occuring if file paths with spaces is used. + +################################################################################################ + +# File system check +# We don't allow writing to SD card. + +#Sed is here to remove any trailing spaces and crap like blank lines +INPUT_FILESYSTEM=$(df -h "${1}" | awk -F ' ' 'FNR> 1 {print $1}' | grep -i -E "/dev/sd?|/dev/hd?" | sed '/^\s*$/d' | wc -l) + +if [[ "${INPUT_FILESYSTEM}" -eq 0 ]]; then #if input file (first file printed in bash) filesystem does not start with /dev/sdX + kdialog --error "Image(s) are in a SD Card. Please move them your local or external storage and try again." + exit +fi + +################################################################################################ + +#We get the directory just from the first filename. Pwd should be easier, but bugged, so... +INPUT_DIR=$(dirname "${1}") +DIR_BASENAME=$(echo "${INPUT_DIR}" | rev | cut -d/ -f 1 | rev) + +echo "DEBUG: Input dir is $INPUT_DIR" + +mkdir -p "${INPUT_DIR}"/converted_dual_iso + +echo "DEBUG: 'converted_dual_iso' directory created" + +############################################################################################ + +####PROGRESSBAR STUFF - BEGIN +LABELTEXT='Processing RAW images...' +numargs=$# # Number of all files +tics=100 # Percentage tics +inc=0 # Current file number +mltp=1000 # Percentage multiplier for bash + +dbusRef=$(kdialog --title "Dual ISO (folder: ${DIR_BASENAME})" --progressbar "$LABELTEXT" $tics) +qdbus $dbusRef showCancelButton true + +####PROGRESSBAR STUFF - END + +while [[ $# -gt 0 ]] && [[ $(qdbus $dbusRef wasCancelled) == "false" ]]; do + + INPUT="${1}" #Input file path, full path like: /home/myhome/IMG_4021.CR2 + OLDFILE_CR2=$(basename "${INPUT}") #Output as IMG_4021.CR2 (for example) + + # Once we do this, it's very clear which kind of CR2 file we're talking about here. + NEWFILE_CR2=$(basename "${INPUT}" | sed 's/\.\w*$/_dualiso.CR2/') + + # Converted Dual ISO file. + NEWFILE_DNG=$(basename "${INPUT}" | sed 's/\.\w*$/_dualiso.DNG/') + + #If converted Dual ISO exists already, we skip the conversion process. This passes only if the file doesn't exist. + if [[ ! -e "${INPUT_DIR}"/converted_dual_iso/"${NEWFILE_DNG}" ]]; then + + if [[ $(cr2hdr --dry-run "${INPUT}" | grep "Interlaced ISO detected" | wc -l) == 1 ]]; then # Test an input file for Dual ISO. + + echo "Interlaced ISO detected: ${OLDFILE_CR2}" + + #Rename detected dual ISO CR2 file with a proper prefix (so that we can distinguish Dual ISO images from "normal" CR2 files) + mv "${INPUT_DIR}"/"${OLDFILE_CR2}" "${INPUT_DIR}"/"${NEWFILE_CR2}" + + #Input we will use from this point is the renamed file, so we set INPUT variable to point to the renamed file. + INPUT="${INPUT_DIR}"/"${NEWFILE_CR2}" + + cr2hdr --process "${INPUT}" # Process a valid input file. + + mv "${INPUT_DIR}"/"${NEWFILE_DNG}" "${INPUT_DIR}"/converted_dual_iso/ # Move converted Dual ISO. + + # Add Subject=Dual-ISO tag for every Dual ISO CR2 file. + echo "Writing new EXIF/XMP tag Subject: Dual ISO CR2" + exiftool -xmp:subject='Dual ISO CR2' "${INPUT_DIR}"/"${NEWFILE_CR2}" -overwrite_original + + fi + fi + +############################################## + + ####PROGRESSBAR STUFF - BEGIN + let inc++ + + #Percentage needs to be calculated like this due to bash rounding limitations... + PERCENT_VALUE=$((($mltp*$tics)/(200*$numargs/$inc % 2 + $mltp*$numargs/$inc))) + #Output: 20, 40, 59, 80, 100 etc. + + qdbus $dbusRef Set "" "value" $PERCENT_VALUE; + qdbus $dbusRef setLabelText "$LABELTEXT ($inc/$numargs)"; + ####PROGRESSBAR STUFF - END + + shift #Process next CR2/DNG file... +done + +############################################## + +#Close processing window if cancelled event has been triggered. + +####PROGRESSBAR STUFF - BEGIN +# If the process was cancelled, remove tmp file and exit the script. +if [[ ! $(qdbus $dbusRef wasCancelled) == "false" ]]; then + exit +fi + +############################################## + +#Close processing window if not cancelled and processing finished. + +qdbus $dbusRef close +####PROGRESSBAR STUFF - END + +############################################## + +if [ $(pgrep -x 'cr2hdr' | wc -l) == 0 ]; then + notify-send 'Dual ISO' -i image-x-krita 'Conversion done!' +fi + +############################################################################################ + +QUESTCOUNT=0 #Ask this question only once + +#Dual ISO (Subject only defined in converted Dual ISO DNG images) +for i in $(find "${INPUT_DIR}" -maxdepth 1 -type f -iname "*.DNG"); do + if [[ ! -z $(echo -n $i) ]] && [[ $(exiftool $i |grep --max-count=1 "Subject" | sed -e 's/.*: //g') == *"Dual-ISO"* ]] ; then + + if [[ $QUESTCOUNT == 0 ]]; then + QUESTION=$(kdialog --yesno "More Dual ISO files detected in '$(echo ${INPUT_DIR} | rev | cut -d/ -f1 | rev)' main folder. Do you want to move these files into 'converted_dual_iso' folder?";) + echo $QUESTION + MOVEALL=true + let QUESTCOUNT++ + else + MOVEALL=false + fi + + if [[ $MOVEALL == true ]]; then + mv $i "${INPUT_DIR}"/converted_dual_iso/ + echo "DEBUG: all detected Dual ISO images moved to 'converted_dual_iso' folder" + fi + + fi +done + +############################################################################################ + +#If there are no files converted, we delete converted_dual_iso folder +if [[ $(ls "${INPUT_DIR}"/converted_dual_iso | wc -l) == 0 ]]; then + rm -Rf "${INPUT_DIR}"/converted_dual_iso + echo "DEBUG: 'converted_dual_iso' empty, so deleted" +fi + +exit diff --git a/4_scripts/imagetools_03_raw_resolution-baseline.sh b/4_scripts/imagetools_03_raw_resolution-baseline.sh new file mode 100644 index 0000000..79924b8 --- /dev/null +++ b/4_scripts/imagetools_03_raw_resolution-baseline.sh @@ -0,0 +1,519 @@ +#!/bin/bash + +# Add CR2 tags: Baseline, Subject (to distinguish Single & Dual ISOs) +# Copyright (C) 2017 Pekka Helenius +# +# 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 the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +############################################### + +# File system check +# We don't allow writing to SD card. + +#Sed is here to remove any trailing spaces and crap like blank lines +INPUT_FILESYSTEM=$(df -h "${1}" | awk -F ' ' 'FNR> 1 {print $1}' | grep -i -E "/dev/sd?|/dev/hd?" | sed '/^\s*$/d' | wc -l) + +if [[ "${INPUT_FILESYSTEM}" -eq 0 ]]; then #if input file (first file printed in bash) filesystem does not start with /dev/sdX + kdialog --error "Image(s) are in a SD Card. Please move them your local or external storage and try again." + exit +fi + +################################################################################################ + + +#We get the directory just from the first filename. Pwd should be easier, but bugged, so... +INPUT_DIR=$(dirname "${1}") +DIR_BASENAME=$(echo "${INPUT_DIR}" | rev | cut -d/ -f 1 | rev) + +#Camera resolution in pixels (absolute limit, we can't exceed these pixel values!) +C5DMK3_WIDTH=5796 +C5DMK3_HEIGHT=3870 + +# In a case or emergency (can't open a picture etc), revert this values to 5760 x 3840 + +################################################################################################ + +####PROGRESSBAR STUFF - BEGIN +LABELTEXT='Processing RAW images...' +numargs=$# # Number of all files +tics=100 # Percentage tics +inc=0 # Current file number +mltp=1000 # Percentage multiplier for bash + +dbusRef=$(kdialog --title "EXIF Tags (folder: ${DIR_BASENAME})" --progressbar "$LABELTEXT" $tics) +qdbus $dbusRef showCancelButton true + +####PROGRESSBAR STUFF - END + +while [[ $# -gt 0 ]] && [[ $(qdbus $dbusRef wasCancelled) == "false" ]]; do + +################################################################ + +# Values that change during the while loop (differ from file to file) + + INPUT="${1}" + + INPUT_BASENAME=$(basename "${INPUT}" | cut -f 1 -d '.') + INPUT_EXTENSION=$(echo $(basename "${INPUT}" | cut -f 2 -d '.' | sed '/^\s*$/d')) #Get the correct file extension for an input file (so the new one will use the same) + + SUBJECT=$(exiftool "${INPUT}" | grep "Subject") + SUBJECT_SINGLEISO=$(exiftool "${INPUT}" | grep "Subject" | grep "Single ISO") + SUBJECT_DUALISO=$(exiftool "${INPUT}" | grep "Subject" | grep "Dual ISO") + + #This is just for compatibility + SUBJECT_DUALISO_OLD=$(exiftool "${INPUT}" | grep "Subject" | grep "Dual-ISO") + + BASELINES=$(exiftool "${INPUT}" | grep "Baseline Exposure") + + C5DMK3_CHECK=$(exiftool "${INPUT}" |grep -i "5D Mark III" |wc -l) + CROPHEIGHT_CHECK_VALUE=$(echo -n $(exiftool "${INPUT}" |grep -i "Cropped Image Height" | sed 's/[^0-9]*//g')) + + ISO_VALUE=$(echo -n $(exiftool "${INPUT}" | grep "Recommended Exposure Index" | grep -v "Sensitivity Type" | sed 's/[^0-9]*//g')) + +################################################################ + +# FIRST CHECK FOR INDIVIDUAL FILE + + ################################ + # CR2 FILES + # + # Input file is CR2 or cr2 + + if [[ "${INPUT_EXTENSION}" == "CR2" ]] || [[ "${INPUT_EXTENSION}" == "cr2" ]]; then + + ########### + # Dual ISO - unprocessed CR2 (NOTE: THIS CHECK IS SLOW) + + if [[ $(cr2hdr --dry-run "${INPUT}" | grep "Interlaced ISO detected" | wc -l) == 1 ]]; then # Test an input file for Dual ISO. + + echo "${INPUT_BASENAME}: Dual ISO CR2 image. Skipping." + IS_SINGLE_CR2=false + + else + IS_SINGLE_CR2=true + fi + + if [[ $IS_SINGLE_CR2 == true ]]; then + ########### + # Single ISO - CR2 + + # Subject Tag + # + if [[ $(echo "${SUBJECT}" | sed '/^\s*$/d' | wc -l) == 0 ]]; then + + echo "${INPUT_BASENAME}: Add a new Subject tag." + SUBJECT_TAG='Single ISO CR2' + PROCESS_SUBJECT=true + + else + + echo "${INPUT_BASENAME} is a Single ISO image and has a Subject tag already." + PROCESS_SUBJECT=false + + fi + + # Baseline Tags + # + if [[ $(echo "${BASELINES}" | sed '/^\s*$/d' | wc -l) == 0 ]]; then + + echo "${INPUT_BASENAME}: Add new Baseline tags." + PROCESS_BASELINE=true + + else + + echo "${INPUT_BASENAME}: Baseline tags exist. Skipping." + PROCESS_BASELINE=false + + fi + + if [[ $CROPHEIGHT_CHECK_VALUE != $C5DMK3_HEIGHT ]]; then + + echo "${INPUT_BASENAME}: New resolution, $C5DMK3_WIDTH x $C5DMK3_HEIGHT." + PROCESS_SIZE=true + + else + + echo "${INPUT_BASENAME}: Has correct resolution already." + PROCESS_SIZE=false + + fi + fi + + ################################ + # DNG FILES + # + # Input file is DNG or dng + + elif [[ "${INPUT_EXTENSION}" == "DNG" ]] || [[ "${INPUT_EXTENSION}" == "dng" ]]; then + + ########### + # DNG with missing Subject Tag + + if [[ $(echo "${SUBJECT}" | sed '/^\s*$/d' | wc -l) == 0 ]]; then + + echo "${INPUT_BASENAME}: Add a new Subject tag." + SUBJECT_TAG='Single ISO CR2' + PROCESS_SUBJECT=true + + #We don't update size tags. See reason below. + #Baseline tags have already been written by Adobe converter. + PROCESS_SIZE=false + PROCESS_BASELINE=false + + ########### + # DNG with updated Subject Tag + + elif [[ $(echo "${SUBJECT_SINGLEISO}" | sed '/^\s*$/d' | wc -l) != 0 ]]; then + + echo "${INPUT_BASENAME}: Subject tag exists. Skipping." + PROCESS_SUBJECT=false + + #We don't update size tags. See reason below. + #Baseline tags have already been written by Adobe converter. + PROCESS_SIZE=false + PROCESS_BASELINE=false + + ########### + # New Dual ISO - DNG + + elif [[ $(echo "${SUBJECT_DUALISO}" | sed '/^\s*$/d' | wc -l) != 0 ]]; then + + echo "${INPUT_BASENAME}: Dual ISO image with proper tags. Skipping." + + # Tags have already be written by updated cr2hdr. + PROCESS_SUBJECT=false + PROCESS_SIZE=false + PROCESS_BASELINE=false + + ########### + # Old Dual ISO - DNG + + elif [[ $(echo "${SUBJECT_DUALISO_OLD}" | sed '/^\s*$/d' | wc -l) != 0 ]]; then + + echo "${INPUT_BASENAME}: old Dual ISO image. Update Subject & Baseline tags." + exiftool -xmp:subject= "${INPUT}" -overwrite_original #Clear old tag + + PROCESS_SUBJECT=true + SUBJECT_TAG='Dual ISO DNG' + + PROCESS_SIZE=false + PROCESS_BASELINE=true #Old dual ISOs don't have this one. + + ################################ + + fi + + fi + +################################################################ +# Suffix for the new file name + +# U = Uncropped (PROCESS_SIZE) +# S = Subject Tag (PROCESS_SUBJECT) +# B = Baseline Tags (PROCESS_BASELINE) + + # false, false, false + if [[ $PROCESS_SUBJECT == false ]] && [[ $PROCESS_BASELINE == false ]] && [[ $PROCESS_SIZE == false ]]; then + + #WRITENEWFILE=false + SUFFIX= + + # true, true, true + elif [[ $PROCESS_SUBJECT == true ]] && [[ $PROCESS_BASELINE == true ]] && [[ $PROCESS_SIZE == true ]]; then + + #WRITENEWFILE=true + SUFFIX=_USB + + # true, true, false + elif [[ $PROCESS_SUBJECT == true ]] && [[ $PROCESS_BASELINE == true ]] && [[ $PROCESS_SIZE == false ]]; then + + #WRITENEWFILE=true + SUFFIX=_SB + + # false, true, true + elif [[ $PROCESS_SUBJECT == false ]] && [[ $PROCESS_BASELINE == true ]] && [[ $PROCESS_SIZE == true ]]; then + + #WRITENEWFILE=true + SUFFIX=_UB + + # true, false, true + elif [[ $PROCESS_SUBJECT == true ]] && [[ $PROCESS_BASELINE == false ]] && [[ $PROCESS_SIZE == true ]]; then + + #WRITENEWFILE=true + SUFFIX=_US + + # false, true, false + elif [[ $PROCESS_SUBJECT == false ]] && [[ $PROCESS_BASELINE == true ]] && [[ $PROCESS_SIZE == false ]]; then + + #WRITENEWFILE=true + SUFFIX=_B + + # true, false, false + elif [[ $PROCESS_SUBJECT == true ]] && [[ $PROCESS_BASELINE == false ]] && [[ $PROCESS_SIZE == false ]]; then + + #WRITENEWFILE=true + SUFFIX=_S + + # false, false, true + elif [[ $PROCESS_SUBJECT == false ]] && [[ $PROCESS_BASELINE == false ]] && [[ $PROCESS_SIZE == true ]]; then + + #WRITENEWFILE=true + SUFFIX=_U + + fi + +################################################################ + + # RESOLUTION TAGS MANIPULATION - non-Dual ISO CR2 only + + # 1) Check if Size process variable is true + # 2) If question "Do we have a 5D Mark string in the file?" does not return 0, E.G. the camera model is 5D Mark 3... + # And if all previous checks pass, then we do our tricks here. + + if [[ $PROCESS_SIZE == true ]] && [[ $C5DMK3_CHECK != 0 ]]; then + + # According to file analysis done with CR2 and DNG files, Cropped & Exif Width/Height tags should be written in a CR2 files. + # CR2 files require only Cropped Image Height/Width values, but if we convert an uncropped CR2 file into DNG, we get wrong picture size. + # To correct this for DNG files, Exif Height/Witdh values are required, too. + + # WHY WE DON'T CHANGE EXIF TAGS FOR DNG FILES HERE? + # We can't uncrop DNG file procuded by Adobe algorithms (Adobe DNG Converter or raw2dng). This is because Adobe's method writes a tag named + #"Default Crop Size" which can't be changed afterwards without rendering the image unusable in Adobe Camera Raw software. I assume Camera Raw + # does some comparison check between dimensions defined in "Default Crop Size" and some of the exif-unwritable Width/Height values, and if + # there's a mismatch, the file can't be opened in Adobe Camera Raw software. I tested it so an image that can't be opened in ACR, is still + # usable in some other RAW processing software (because their check for EXIF value tags differ). + + # Every time I edited "Default Crop Size" value in DNG, ACR gave me an error claiming the file is unsupported or corrupted. + + exiftool -CroppedImageWidth=$C5DMK3_WIDTH -CroppedImageHeight=$C5DMK3_HEIGHT -ExifImageWidth=$C5DMK3_WIDTH -ExifImageHeight=$C5DMK3_HEIGHT "${INPUT}" -overwrite_original + echo -e "${INPUT_BASENAME}: Image dimensions updated to $C5DMK3_WIDTH x $C5DMK3_HEIGHT.\n" + # Other useful Height/Width tags are as follows: + + # -OriginalImageWidth + # -OriginalImageHeight + + # -RelatedImageWidth + # -RelatedImageHeight + + fi + + ################################################################ + + # BASELINE TAGS ADDITION - non-Dual ISO CR2 only + + # 1) We can request that PROCESS variable returns true though it's set to false in Dual ISO CR2 images too. These CR2 images have Baseline values + # already added into EXIF metadata since 01/07/2017 (cr2hdr code patched). + + # 2) We check for Canon 5D Mark 3 here + + # NOTE: We don't care about the image resolution here. + + if [[ $PROCESS_BASELINE == true ]] && [[ $C5DMK3_CHECK != 0 ]]; then + + # The following tags (with their respective values) are being used in DNG files converted from CR2 files of Canon 5D Mark 3 camera. Because CR2 files are mostly equal to + # DNG files but these tags don't exist inside CR2 files, we can add them as done in the following lines. + + # ###################################################### + # + # Camera Model: Canon EOS 5D Mark III + + # ISO Value Baseline Exposure Value + # + # 100 0.25 + # 125 0.25 + # 200 0.25 + # 250 0.25 + # 400 0.25 + # 500 0.25 + # 800 0.25 + # 1000 0.25 + # 1600 0.25 + # 2000 0.25 + # 3200 0.25 + # 4000 0.25 + # 6400 0.25 + # 8000 0.25 + # 12800 0.25 + # 16000 0.25 + # 25600 0.25 + # + # 50 -0.75 + # 160 0.02 + # 320 0.01 + # 640 0.01 + # 1250 0.01 + # 2500 0.01 + # 5000 0.01 + # 10000 0.01 + # 20000 0.01 + # 51200 0.36 + # 102400 0.36 + # + # ###################################################### + # + # Same values for all ISOs: + # + # Baseline Noise 0.8 + # Baseline Sharpness 1.2 + # Bayer Green Split 100 + # + # ###################################################### + # + # Camera Profiles in Adobe Camera RAW - Baseline Exposure Offsets: + # + # All Canon EOS 5D Mark 3 profiles (Standard, Neutral, Landscape etc.): -0.25 + # Adobe Standard Profile: 0.00 + # + # ###################################################### + + # We Do ISO check with Exposure Index value (It returns the same value than used ISO, and works with ISO 102400, too) + + if [[ $ISO_VALUE == 50 ]]; then + BL_EXP=-0.75 + + elif [[ $ISO_VALUE == 160 ]]; then + BL_EXP=0.02 + + elif [[ $ISO_VALUE == 51200 ]] || [[ $ISO_VALUE == 102400 ]]; then + BL_EXP=0.36 + + elif [[ $ISO_VALUE == 320 ]] || [[ $ISO_VALUE == 640 ]] || [[ $ISO_VALUE == 1250 ]] || [[ $ISO_VALUE == 2500 ]] || [[ $ISO_VALUE == 5000 ]] || [[ $ISO_VALUE == 10000 ]] || [[ $ISO_VALUE == 20000 ]]; then + BL_EXP=0.01 + + else + BL_EXP=0.25 + fi + + exiftool -BaselineExposure=$BL_EXP -BaselineNoise=0.8 -BaselineSharpness=1.2 -BayerGreenSplit=100 "${INPUT}" -overwrite_original + + echo -e "${INPUT_BASENAME}: Baseline tags added.\n" + + fi + + # ###################################################### + + ################################################################ + + # SUBJECT TAG ADDITION + + if [[ $PROCESS_SUBJECT == true ]] && [[ $C5DMK3_CHECK != 0 ]]; then + + exiftool -xmp:subject="$SUBJECT_TAG" "${INPUT}" -overwrite_original + + echo -e "${INPUT_BASENAME}: New Subject tag added: $SUBJECT_TAG\n" + + fi + + ################################################################ + + # FILE SUFFIX ADDITION + + #if [[ $WRITENEWFILE == true ]]; then + + exiftool "-FileModifyDate&1 | grep -E 'opened|frames' | awk '{print $2}' | sed 's/.*\///' | sed -e '1 i\Files:' -e '4 i\\nDNG Frames:' )" --title "MLV Information"; diff --git a/4_scripts/imagetools_06_exif_deletedata.sh b/4_scripts/imagetools_06_exif_deletedata.sh new file mode 100644 index 0000000..f80da2b --- /dev/null +++ b/4_scripts/imagetools_06_exif_deletedata.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Delete all exif metadata from selected images with Exiftool +# Copyright (C) 2017 Pekka Helenius +# +# 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 the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +############################################### + +#We get the directory just from the first filename. Pwd should be easier, but bugged, so... +INPUT_DIR=$(dirname $1) + +mkdir -p $INPUT_DIR/nometadata + +#kdialog --yesnocancel "Do you really want to delete EXIF data for the selection?"; + +#if [ "$?" = 0 ]; then + while [ $# -gt 0 ]; do + + EXTENSION=$(echo $1 | rev | cut -f 1 -d '.' | rev) #Get the correct file extension for an input file (so the new one will use the same) + + OLDFILE=$(basename $1 | sed "s/\.\w*$/.$EXTENSION/") + NEWFILE=$(basename "$OLDFILE" | sed "s/\.\w*$/_nometadata.$EXTENSION/") + + exiftool -all= $INPUT_DIR/$OLDFILE -o $INPUT_DIR/nometadata/$NEWFILE + shift + done + +#Delete empty metadata folder (if it is) +if [[ $(ls $INPUT_DIR/nometadata/ | wc -l) == 0 ]]; then + rm -Rf $INPUT_DIR/nometadata/ +fi diff --git a/4_scripts/imagetools_06_exif_deletedata_critical.sh b/4_scripts/imagetools_06_exif_deletedata_critical.sh new file mode 100644 index 0000000..a348cdf --- /dev/null +++ b/4_scripts/imagetools_06_exif_deletedata_critical.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Delete critical metadata from an image or images using Exiftool +# Copyright (C) 2017 Pekka Helenius +# +# 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 the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +############################################### + +#We get the directory just from the first filename. Pwd should be easier, but bugged, so... +INPUT_DIR=$(dirname $1) + +#kdialog --yesnocancel "Do you really want to delete EXIF data for the selection?"; + +#if [ "$?" = 0 ]; then + while [ $# -gt 0 ]; do + + EXTENSION=$(echo $1 | rev | cut -f 1 -d '.' | rev) #Get the correct file extension for an input file (so the new one will use the same) + + FILE=$(basename $1 | sed "s/\.\w*$/.$EXTENSION/") + + exiftool -xmp:subject= -Software= -Version= -creatortool= -historysoftwareagent= -PhotoshopThumbnail= -FocalLength= -Lens= -FNumber= -ApertureValue= -LensInfo= -LensModel= -ExposureTime= -MaxApertureValue= -SerialNumber= -Make= -ExposureMode= -WhiteBalance= -Flash= -MeteringMode= -ExposureCompensation= -ShutterSpeedValue= -RecommendedExposureIndex= -SensitivityType= -LensSerialNumber= -FocalPlaneYResolution= -FocalPlaneXResolution= -FocalPlaneResolutionUnit= -XResolution= -YResolution= -ResolutionUnit= -iso= -ColorSpace= -Model= -ExposureProgram= -adobe:all= -xmp:all= -photoshop:all= $INPUT_DIR/$FILE -overwrite_original + shift + done +# kdialog --msgbox "Exif metadata deleted!" +#else +# exit 0 +#fi diff --git a/4_scripts/imagetools_07_ale_stack.sh b/4_scripts/imagetools_07_ale_stack.sh new file mode 100644 index 0000000..8e60526 --- /dev/null +++ b/4_scripts/imagetools_07_ale_stack.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Stack TIFF images with Anti-Lamenessing Engine (ALE) +# Copyright (C) 2017 Pekka Helenius +# +# 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 the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +############################################### + +#We get the directory just from the first filename. Pwd should be easier, but bugged, so... +INPUT_DIR=$(dirname $1) + +#First & Last file names (without suffixes) +for last; do true; done +FIRST=$(basename $1 | cut -f 1 -d '.' | sed 's/IMG_//g') #Name of the first file passed into the script +LAST=$(basename $last | cut -f 1 -d '.' | sed 's/IMG_//g') #Name of the last file passed into the script + + + +echo 'Starting image stacking process using temporary TIFF files.' && \ +ale ./temp_tiff/*.tiff output.tif diff --git a/4_scripts/imagetools_08_geotag.sh b/4_scripts/imagetools_08_geotag.sh new file mode 100644 index 0000000..8fcf86e --- /dev/null +++ b/4_scripts/imagetools_08_geotag.sh @@ -0,0 +1,84 @@ +#!/bin/bash + +# Geotag images +# Copyright (C) 2017 Pekka Helenius +# +# 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 the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +############################################### + +# TODO Coordinate threshold = Grid size is 30x30m? +# TODO Find API for ASTER DEM v2 (better data) + +USERNAME=Fincer #For API (data request) + +############################ + +INTERNET_TEST=$(ping -c 3 nominatim.openstreetmap.org 2>&1 | grep -c "unknown host") #Ping Github three times and look for string 'unknown host' + +if [[ ! $INTERNET_TEST -eq 0 ]]; then #If 'unknown host' string is found, then + echo -e "\nCan't connect to geoservice provider (Nominatim). Please check your internet connection and try again.\n" + exit 1 +fi + +############################ + +for IMAGE in $(echo "${@}"); do + + IMAGE_BASENAME=$(basename "${IMAGE}" | cut -f 1 -d '.') + IMAGE_EXTENSION=$(echo $(basename "${IMAGE}" | cut -f 2 -d '.' | sed '/^\s*$/d')) + + if [[ $(exiftool -n -p '$GPSLatitude,$GPSLongitude' "${IMAGE}" | awk -F ',' '{print NF}') != 2 ]]; then + echo -e "$IMAGE_BASENAME: Missing coordinates. Are you sure you have geotagged the photo?\n" + exit + + else + + LATITUDE=$(exiftool -n -p '$GPSLatitude' "${IMAGE}") + LONGITUDE=$(exiftool -n -p '$GPSLongitude' "${IMAGE}") + + # Clear previous geonames information + exiftool -Location= -LocationShownCity= -LocationShownCountryName= -LocationShownProvinceState= -LocationShownSublocation= -Country-PrimaryLocationName= -Sub-location= -Country= -City= -State= -Province-State= -GPSAltitude= "${IMAGE}" -overwrite_original + + #if [[ $(exiftool -p '$Country-PrimaryLocationName' "${IMAGE}" | awk '{print NF}') != 1 ]]; then + echo -e "$IMAGE_BASENAME: retrieving country information.\n" + reversegeo "${IMAGE}" + #fi + + # Reference: http://www.geonames.org/export/web-services.html + # Get elevation by retrieving a ASTER DEM value from GeoNames API server, grid size 30x30m + # There are several error factors: + # DEM Grid size + # General inaccurancies in DEM model + # Geoid model & projection errors + # Coordinate errors + # Variations in (estimated) height values + + # So the retrieved elevation value is just a rough estimation here + + ALTITUDE=$(curl -s "http://api.geonames.org/astergdem?lat=$LATITUDE&lng=$LONGITUDE&username=$USERNAME") + + # IF successful answer, then + if [[ $ALTITUDE =~ '^[0-9]+$' ]]; then + + exiftool -GPSAltitude=$ALTITUDE "${IMAGE}" -overwrite_original + echo -e "$IMAGE_BASENAME: Altitude value updated.\n" + + else + # TODO IF NOT successful, try again for 2 times, then abort + + echo -e "$IMAGE_BASENAME: Couldn't retrieve altitude value.\n" + +done diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..dd844af --- /dev/null +++ b/README.md @@ -0,0 +1,109 @@ +# Linux camera tools for Canon DSLR owners + +- main target group: + + - Linux users who own a Canon DSLR camera and may have Magic Lantern firmware on their workflow + + - Linux users who own a Canon DSLR camera and are interested in exporting statistics from their CR2 raw images + + - ...and others alike + +## About + +### Camera statistics + +- Create image statistics easily with a right-click menu entry in Dolphin file manager. Exports statistics from RAW images and draws various plots based on this data + + - Support for following statistics (with GNU Plot): + + - Temperatures & ISOs + + - **NOTE** GNU Plots are not yet supported for + + - Apertures, Exposures & ISOs + + - Focal Lengths & Lenses + + - Shooting & Focus Modes + +- Possible to extract all or selected camera RAW metadata and save it into a CSV file for post-processing. + +### Dual ISO conversion + +- Convert Magic Lantern dual ISO cr2 files easily with a right-click menu entry in Dolphin file manager. + +- Support for individual image and multiple images selection. + +- Is able to distinguish single ISO CR2 files from dual ISO CR2 files. You can select multiple CR2 files without need to care about this issue. + +- By default, CR2 images contain metadata which crop them in most image viewers. This script removes all cropping tags and you get full-sized images for your post-processing editors as a result. + +- Adds `--dry-run` support for cr2hdr. Therefore, the tool can be used just to check whether a CR2 image is a dual ISO image or not. Useful option in scripting & programming. + +### Bootable SD Card + +- Create a Magic Lantern bootable SD card for your Canon DSLR. Code is released by Magic Lantern project under GPL license. + +### MLV info + +- Print information about Magic Lantern MLV files on KDE/Plasma desktop environment + +### Exiftool - delete critical / all metadata + +- Scripts for deleting all or critical (identifiable) metadata from image files. Preferred usage: integrated with Dolphin file manager. + +### ALE stack + +- Stack multiple non-RAW TIFF images in a directory + +## Repository contents + +### 0_cr2hdr_tool + +Source files for customized cr2hdr tool, required by scripts (statistics, dual ISO conversions...) in this repository. + +### 1_magiclantern_bootablecard_linux + +Source files for creating an Arch Linux package for Magic Lantern bootable SD card tool. + +### 2_gnuplot_patch + +Patch file for GNU Plot for better QT integration. Adds and alters some features which benefit generated statistics. Tested with GNU Plot 5.0.6. + +### 3_desktop_files_for_kde-plasma-dolphin + +Dolphin file manager desktop integration for scripts in this repository. + +### 4_scripts + +Main scripts for exporting statistics, doing image conversions...etc. + +### sample_images + +Sample images. + +## Screenshots + +Temperature & ISO plots for 20 images: + +![](sample_images/image_5.png) + +Temperature & ISO plots for 2 images: + +![](sample_images/image_2.png) + +Exported statistics: + +![](sample_images/image_1.png) + +Dolphin menu entries (KDE/Plasma): + +![](sample_images/image_4.png) + +Statistics export progress bar (KDE/Plasma): + +![](sample_images/image_3.png) + +## License + +Contents of this repository have been published under GPLv2. diff --git a/sample_images/image_1.png b/sample_images/image_1.png new file mode 100644 index 0000000..b8dc7db Binary files /dev/null and b/sample_images/image_1.png differ diff --git a/sample_images/image_2.png b/sample_images/image_2.png new file mode 100644 index 0000000..269426d Binary files /dev/null and b/sample_images/image_2.png differ diff --git a/sample_images/image_3.png b/sample_images/image_3.png new file mode 100644 index 0000000..18e47a4 Binary files /dev/null and b/sample_images/image_3.png differ diff --git a/sample_images/image_4.png b/sample_images/image_4.png new file mode 100644 index 0000000..c43759a Binary files /dev/null and b/sample_images/image_4.png differ diff --git a/sample_images/image_5.png b/sample_images/image_5.png new file mode 100644 index 0000000..69ef4ee Binary files /dev/null and b/sample_images/image_5.png differ