Code Monkey home page Code Monkey logo

photo_scale_timestamp_script's Introduction

Timestamp and scale all the images.

These scripts write the time and date from the EXIF date of an image, as text onto that image, and scales the image into a smaller one. And this for a all the images in a dir.

Scripts

This is done via one of these scripts:

  1. timestamp_files.sh, to add a timestamp from the EXIF data to all the image in the input dir and write output to the output dir.
  2. timestamp_file.sh, does the same as 'timestamp_files.sh', but only for 1 file and needs to be called with cli variables.
  3. timesstamp_parallel.sh, does the same as 'timestamp_files.sh', but only in parallel in stead of sequential. Makes use of 'timestamp_file.sh'.
  4. timestamp-rescale.sh, to scale all the images in the input dir into a smaller images in the output dir..
  5. combine-tiemstamp-rescale.sh, runs first the timestamp and then the rescale.

These scripts is using:

  1. 'convert' and 'identify', which is part of 'imagemagick'.
  2. the font Roboto, which you can replace in the script by another.
  3. Part of every GNU ecosystem:
  4. 'bash' (for running script).
  5. 'date' function/application.
  6. 'echo' (for overal usage).
  7. 'tr', 'cut' (for date format).
  8. 'grep', 'ls', 'wc' (for progressbar).

Backlog

  1. [V] count input files
  2. [V] count timestamped files
  3. [V] count scaled files
  4. [V] start, stop, duration time feedback
  5. [-] optimize scale script to use parallelization
  6. [-] run renamejpg from the combine script on the input file directory
  7. [-] if scaled/timestamped dir are with files, by default rename dir (overwrite with cli flag)

You need to install imagemagick.

install

  • sudo apt install imagemagick
  • sudo apt install parallel

test install

  • convert logo: logo.gif
  • convert -version
  • identify -version

List fonts to see if roboto is there.

  • fc-list | grep -i arial
  • convert -list font|grep Liberation-Sans

Used resources

On CONVERT

  1. https://legacy.imagemagick.org/Usage/annotating
  2. https://legacy.imagemagick.org/Usage/draw/#annotate
  3. https://legacy.imagemagick.org/script/command-line-options.php?#annotate

On drawing with ImageMagick

  1. http://www.imagemagick.org/script/command-line-processing.php#geometry

On ImageMagick

  1. https://github.com/ImageMagick/ImageMagick
  2. https://techpiezo.com/linuxinstall-imagemagick-in-ubuntu-20-04-lts

On BASH

  1. https://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-5.html
  2. https://tldp.org/LDP/abs/html/varassignment.html
  3. https://www.cyberciti.biz/faq/bash-loop-over-file
  4. https://linuxize.com/post/bash-concatenate-strings
  5. https://en.wikibooks.org/wiki/Cut
  6. https://www.geeksforgeeks.org/date-command-linux-examples
  7. https://www.cyberciti.biz/faq/check-if-a-directory-exists-in-linux-or-unix-shell
  8. https://www.cyberciti.biz/faq/howto-check-if-a-directory-exists-in-a-bash-shellscript

in regards to Progress bar

  1. https://stackoverflow.com/questions/238073/how-to-add-a-progress-bar-to-a-shell-script
  2. https://stackoverflow.com/questions/12498304/using-bash-to-display-a-progress-indicator
  3. https://stackoverflow.com/questions/38339434/making-simple-shell-progress-bar
  4. https://stackoverflow.com/questions/23630501/how-to-progress-bar-in-bash

in regards to count files

  1. https://stackoverflow.com/questions/11307257/is-there-a-bash-command-which-counts-files

in regards to seconds and minutes

  1. https://stackoverflow.com/questions/8903239/how-to-calculate-time-elapsed-in-bash-script

in regards to parrrel

  1. https://stackoverflow.com/questions/29058741/need-to-cropresize-300000-files-runtime-4-days-how-can-i-speed-up-my-bash
  2. https://www.gnu.org/software/bash/manual/html_node/GNU-Parallel.html
  3. https://www.gnu.org/software/parallel/parallel_tutorial.html
  4. https://www.cyberciti.biz/faq/how-to-run-command-or-code-in-parallel-in-bash-shell-under-linux-or-unix/
  5. https://saveriomiroddi.github.io/Running-shell-commands-in-parallel-via-gnu-parallel
  6. https://unix.stackexchange.com/questions/103920/parallelize-a-bash-for-loop
  7. https://unix.stackexchange.com/questions/101632/running-thousands-of-curl-background-processes-in-parallel-in-bash-script
  8. https://unix.stackexchange.com/questions/575327/can-gnu-parallel-execute-a-bash-script-25000-times-per-seconds-and-parallel-proc
  9. https://opensource.com/article/18/5/gnu-parallel
  10. https://www.youtube.com/playlist?list=PL284C9FF2488BC6D1

On CODE

in regards to Timestamp with imagemagick

  1. https://ubuntuforums.org/showthread.php?t=1235238
  2. https://legacy.imagemagick.org/discourse-server/viewtopic.php?t=20213
  3. https://legacy.imagemagick.org/discourse-server/viewtopic.php?t=9155
  4. https://stackoverflow.com/questions/51922126/how-to-format-date-and-time-with-imagemagicks-identify-utility
  5. https://stackoverflow.com/questions/26654709/extract-exif-data-as-text-using-imagemagick

in regards to Resize with imagemagick

  1. https://stackoverflow.com/questions/8707694/batch-resize-images-into-new-folder-using-imagemagick
  2. https://askubuntu.com/questions/135477/how-can-i-scale-all-images-in-a-folder-to-the-same-width
  3. https://askubuntu.com/questions/1068850/resize-multiple-images-with-imagemagick-from-a-folder-to-other-and-keep-the-nam
  4. https://gordonlesti.com/imagemagick-resize-all-images-in-a-directory
  5. https://legacy.imagemagick.org/Usage/resize/#sample
  6. https://askubuntu.com/questions/135477/how-can-i-scale-all-images-in-a-folder-to-the-same-width
  7. https://askubuntu.com/questions/135477/how-can-i-scale-all-images-in-a-folder-to-the-same-width

on FONT

  1. https://askubuntu.com/questions/673615/imagemagick-convert-command-cannot-use-fonts
  2. https://legacy.imagemagick.org/Usage/fonts/
  3. https://codereview.stackexchange.com/questions/88516/bash-script-that-checks-if-font-is-installed-and-installs-it-if-necessary

on Google drive

  1. https://techstreams.medium.com/git-google-drive-simple-git-host-3a84db4fc1fd
  2. https://github.com/labbots/google-drive-upload
  3. https://towardsdatascience.com/uploading-files-to-google-drive-directly-from-the-terminal-using-curl-2b89db28bb06

Example code

of Timestamp

  • identify -format '%[EXIF:*]' image.jpg

  • datetime=$(identify -format "%[EXIF:DateTime]" P1050001.JPG | tr " " "_" | tr ":" "-")

  • inname=$(identify -format "%t" P1050001.JPG)

  • convert P1050001.JPG ${inname}_${datetime}.jpg

  • :: Add the date the photo was taken to the image

  • convert %1 -pointsize 20 -fill black -gravity northwest ^

  • -annotate +0+0 "Date: %DateTime%" "%~p1date_%~n1.jpg"

  • convert fotosin\*.jpg -font Arial -pointsize 32 -fill white -annotate +30+50 %[exif:DateTimeOriginal] \fotosout

of Resize

  • convert -define jpeg:size=250x200 *.jpg -thumbnail 250x200^ -gravity center -extent 250x200 crop/thumbnail-%d.jpeg
  • for i in `ls -1 *jpg`; do convert -resize 50% $i "thumb_$i"; done
  • convert image_file.png -resize 300x300 image_file_resize.png
  • convert "images/*.jpg[250x]" -set filename:base "%[basename]" "images/new_folder/%[filename:base].jpg"

LICENSE

CC BY-SA 4.0 https://github.com/edzob/photo_scale_timestamp_script

photo_scale_timestamp_script's People

Contributors

edzob avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.