A poorly programmed, very naïve system to choose and open images from a given folder's tree. For the chaps over at /ic/
Requirements:
- Common utilities: bash, grep, sed, find, dirname, date, bc, realpath, shuf
- xpdf-utils (I'll consider implementing something with muPDF to actually render the whole page before dumping instead of using pdfimages, later)
- imagemagick
- An image viewer with the filename "img" placed in a directory "crf-helpers" under the same directory as this script (I use IrfanView(Yes, proprietary software) on Windows(Yes))
- The first argument to this viewer is the path to the file
- A PDF viewer with the filename "pdfo" placed in a directory "crf-helpers" under the same directory as this script (I use muPDF based SumatraPDF on windows)
- The first argument to this viewer is the path to the file
- The second argument to this viewer is the pagenumber to the file
- A discretizer executable "disc" placed in a directory "crf-helpers" under the same directory as this script which takes binary ppm or pgm (type 5 and 6) data from standard input(accepting unix style line breaks), and outputs to the standard output (My shoddy source code for disc.c should be provided alongside this. Make sure to compile it in a compiler that is tuned to treat '\n' as only a line feed)
- The first argument to this discretizer is the number of levels the image should be discretized to (unsigned)
- The second argument to this discretizer is the delta that should be applied to each pixel before discretizing (signed, and the delta addition operation is clamped in range [0, pnm's max value])
- An executable "pathtranslate" in a directory "crf-helpers" under the same directory as the script, which translates the paths to something that all previously prescribed programs support
The "Get it Working" guide for newbies
Linux:
- Download the source/Clone this repo
- Get xpdf-utils(or poppler-utils as they're called now apparently), imagemagick, A pdf reader of your choice which can open pdfs at arbitary pages (For example Okular or Evince) and an image viewer of your choice (should atleast be capable of viewing pnm files, so that you can atleast view stuff with the
crf -d 0converting stuff to .ppms and .pgms, with imagemagick handling the rest, but ideally make sure that all the formats that get printed in the file match regex when usingcrf -hare supported") from your distribution's package repositories, or however else you like/can manage - Place crf somewhere on your path
- Make the "crf-helper" directory besides crf
- Compile disc.c with
cc disc.c -g -o discand place it inside the "crf-helper" directory - Make
imgandpdfoshell scripts inside "crf-helper", configure it so that they pass their respective arguments correctly to the pdf and image viewers. - ???
- Profit (Atleast as long as you don't name files with characters that are illegal on windows and ':'. That can break shit.)
Windows:
- Install
GentooCygwin (Latest installer) - In the setup, select where to install cygwin (make note of it for later), select a remote repository and make sure to select whatever version of
gcc-coreis available as the newest. Let it finish installing. - Download the source/Clone this repo
- Install xpdf-utils, imagemagick, IrfanView (Or any other image viewer of your choice) and SumatraPDF (Or any other pdf viewer of your choice).
- Go to the Environment Variables section of control panel, edit the path variable for your user, and add the directories where "pdfimages.exe", "magick.exe" and "pdfinfo.exe" are installed (You can just copy pdfinfo.exe and pdfimages.exe to the "bin" folder of your cygwin installation. Don't do this with magick.exe)
- Place crf in the "bin" folder of your cygwin installation
- Make the "crf-helpers" directory besides crf
- Copy pathtranslate into the "crf-helpers" folder from the last step
- Open Cygwin Terminal from your start menu and enter the following commands (Remember to replace the stuff inside double angular brackets with what it's asking you for, before pasting it in the terminal):
touch /bin/crf-helpers/img /bin/crf-helpers/pdfo echo "export IRFANVIEW_PATH=\"<<INSERT PATH TO IRFANVIEW's i_view64.exe here>>\"" >> ~/.bashrc echo "export SUMATRA_PATH=\"<<INSERT PATH TO Sumatra PDF's exe here>>\"" >> ~/.bashrc echo "export CYGWIN_ROOT_WINPATH=\"<<INSERT PATH to outermost cygwin64 folder. Replace the driveletter part (eg. 'C:\') with the cygwin equivalent (eg. '/cygdrive/c/')>>\"" >> ~/.bashrc chmod +x /bin/crf chmod +x /bin/crf-helpers/* gcc "<<INSERT PATH to [disc.c](disc/disc.c)>> -g -o /bin/crf-helpers/disc" - Remain in the terminal and enter
cd /bin/crf-helpersthere - Enter
notepad img. Save and exit after you paste this into notepad:#!/bin/sh "$IRFANVIEW_PATH" "$1"
- Enter
notepad pdfo. Save and exit after you paste this into notepad:#!/bin/sh pageopt="-page" if [ $2 == "" ] then pageopt="" fi "$SUMATRA_PATH" -new-window -presentation "$pageopt" "$2" "$1"
- Close and repoen the terminal
- ???
- | || || |_
Using the damn thing:
- Wherever your images are neatly organized, copy the path to that folder, pop into the terminal, do
cd <<PASTE the path here>>to get into that directory. - If you just want it to choose a reference for your studies, just enter
crf - If you want it to choose a reference and grayscale it, enter
crf -g - If you want it to choose a reference and then grayscale and discretize it for say, 4 value studies, enter
crf -g -d 4
Example:
