this post was submitted on 30 Jun 2026
14 points (100.0% liked)

unix_surrealism

2900 readers
14 users here now

This community is for sharing original content related to computers, content, surrealism and wizardry.

founded 3 years ago
MODERATORS
 

I tried to make foldable mini-zines from the japanese jesus comic: https://files.catbox.moe/9e0inu.pdf These can be printed on 3 sheets of paper and folded like so: https://slrpnk.net/post/9615309 Sadly, due to page count constraints, i could not put the cover on the third part when keeping all pages as is.

photo of 3 japanese jesus mini-zines

There are two alternative versions available:

In both something is missing, choose your favorite.

They were created using the following script, which you should run in a empty directory:

First Version

#!/bin/sh

# create 3-part mini zine from japanese jesus

check () {
    if [ "$(which $1 2>/dev/null)" == "" ];
    then
        echo "ERROR: missing $1 utility"
        exit 1
    fi
}

echo "checking required tools"
check magick
check pdfjam
check pdfcrop
check wget

rotate () {
    magick convert -rotate -90 $1 $1.tmp.png
    mv $1.tmp.png $1
}

if [ ! -f 000_jjc.png ];then
    echo "downloading source files"
    wget https://img.triapul.cz/jjc.png -O 000_jjc.png
    wget https://img.triapul.cz/christmas.png -O 001_christmas.png
    wget https://img.triapul.cz/jordan_cold_cock.png -O 002_jordan_cold_cock.png
    wget https://img.triapul.cz/40days1.png -O 003_40days1.png
    wget https://img.triapul.cz/40days2.png -O 004_40days2.png
    wget https://img.triapul.cz/third_oni.png -O 005_third_oni.png
    wget https://img.triapul.cz/herod.png -O 006_herod.png
    wget https://img.triapul.cz/mount_8.png -O 007_mount_8.png
    wget https://img.triapul.cz/lazarus1.png -O 008_lazarus1.png
    wget https://img.triapul.cz/danbrown.png -O 009_danbrown.png
    wget https://img.triapul.cz/thread_the_needle.png -O 010_thread_the_needle.png
    wget https://img.triapul.cz/thread_the_needle_2.png -O 011_thread_the_needle_2.png
    wget https://img.triapul.cz/dirtydozen1.png -O 012_dirtydozen1.png
    wget https://img.triapul.cz/dirtydozen2.png -O 013_dirtydozen2.png
    wget https://img.triapul.cz/gethsemane.png -O 014_gethsemane.png
    wget https://img.triapul.cz/pleased_to_meet_you.png -O 015_pleased_to_meet_you.png
    wget https://img.triapul.cz/mrs_robinson.png -O 016_mrs_robinson.png
    wget https://img.triapul.cz/vickers.png -O 017_vickers.png
    wget https://img.triapul.cz/calvary.png -O 018_calvary.png
    wget https://img.triapul.cz/judas.png -O 019_judas.png
    wget https://img.triapul.cz/ghost_in_training.png -O 020_ghost_in_training.png
    wget https://img.triapul.cz/fossberg.png -O 021_fossberg.png
    wget https://img.triapul.cz/constantine.png -O 022_constantine.png


    echo "rotating images"
    rotate 011*.png
    rotate 012*.png
    rotate 013*.png
fi

create_part () {
    pdfjam $2 $3 $4 $5 $6 $7 $8 $9  --a4paper --width 20cm --outfile part$1_tmp1.pdf --delta '1cm 1cm'
    pdfjam part$1_tmp1.pdf 8,7,1,6,2,5,3,4 --a4paper --otheredge --outfile part$1_tmp2.pdf
    pdfjam part$1_tmp2.pdf --a4paper --nup 2x4 --angle 90 --outfile part$1_tmp3.pdf
    pdfcrop part$1_tmp3.pdf part$1_tmp4.pdf
    pdfjam part$1_tmp4.pdf --a4paper --trim '-0.5cm -0.5cm -0.5cm -0.5cm' --outfile part$1_tmp5.pdf
    pdfjam part$1_tmp5.pdf --a4paper --outfile part$1.pdf
}
create_cover () {
    magick convert -gravity NorthWest -pointsize 40 -undercolor white -annotate +0+0 'japanese jesus — part '$2' || https://triapul.cz/' $1 cover$2.png
}

echo "creating covers"
create_cover 000_jjc.png 1
create_cover 000_jjc.png 2
create_cover 015*.png 3

echo "creating pdf files"
create_part 1 cover1.png $(ls 0*.png|head -n8|tail -n7)
create_part 2 cover2.png $(ls 0*.png|head -n15|tail -n7)
create_part 3 cover3.png $(ls 0*.png|tail -n7)

echo "joining pdf files"
pdfjam part1.pdf part2.pdf part3.pdf --a4paper --outfile japanese_jesus.pdf


echo "cleanup"
rm cover* *tmp*.pdf
rm part*.pdf

echo "all done, enjoy japanese_jesus.pdf"
echo "see https://slrpnk.net/post/9615309 on folding"

Second Version

#!/bin/sh

# create 3-part mini zine from japanese jesus

check () {
    if [ -z "$(command -v $1 2>/dev/null)" ];
    then
        echo "ERROR: missing $1 utility"
        exit 1
    fi
}

echo "checking required tools"
check magick
check pdfjam
check pdfcrop
check wget

rotate () {
    magick convert -rotate -90 $1 $1.tmp.png
    mv $1.tmp.png $1
}

join_parts () {
echo "joining pdf files"
pdfjam part1.pdf part2.pdf part3.pdf --a4paper --outfile $1
rm part*.pdf
}

if [ ! -f 000_jjc.png ];then
    echo "downloading source files"
    wget https://img.triapul.cz/jjc.png -O 000_jjc.png
    wget https://img.triapul.cz/christmas.png -O 001_christmas.png
    wget https://img.triapul.cz/jordan_cold_cock.png -O 002_jordan_cold_cock.png
    wget https://img.triapul.cz/40days1.png -O 003_40days1.png
    wget https://img.triapul.cz/40days2.png -O 004_40days2.png
    wget https://img.triapul.cz/third_oni.png -O 005_third_oni.png
    wget https://img.triapul.cz/herod.png -O 006_herod.png
    wget https://img.triapul.cz/mount_8.png -O 007_mount_8.png
    wget https://img.triapul.cz/lazarus1.png -O 008_lazarus1.png
    wget https://img.triapul.cz/danbrown.png -O 009_danbrown.png
    wget https://img.triapul.cz/thread_the_needle.png -O 010_thread_the_needle.png
    wget https://img.triapul.cz/thread_the_needle_2.png -O 011_thread_the_needle_2.png
    wget https://img.triapul.cz/dirtydozen1.png -O 012_dirtydozen1.png
    wget https://img.triapul.cz/dirtydozen2.png -O 013_dirtydozen2.png
    wget https://img.triapul.cz/gethsemane.png -O 014_gethsemane.png
    wget https://img.triapul.cz/pleased_to_meet_you.png -O 015_pleased_to_meet_you.png
    wget https://img.triapul.cz/mrs_robinson.png -O 016_mrs_robinson.png
    wget https://img.triapul.cz/vickers.png -O 017_vickers.png
    wget https://img.triapul.cz/calvary.png -O 018_calvary.png
    wget https://img.triapul.cz/judas.png -O 019_judas.png
    wget https://img.triapul.cz/ghost_in_training.png -O 020_ghost_in_training.png
    wget https://img.triapul.cz/fossberg.png -O 021_fossberg.png
    wget https://img.triapul.cz/constantine.png -O 022_constantine.png


    cp 0*dirtydozen1.png dirtydozen1.png
    cp 0*dirtydozen2.png dirtydozen2.png

    echo "rotating images"
    rotate 011*.png
    rotate 012*.png
    rotate 013*.png
fi

if [ ! -f dirtydozen.png ];then
    magick dirtydozen2.png -chop 0x180 dirtydozen2_chopped.png
    echo "merging dirty dozen"
    magick convert -append dirtydozen1.png dirtydozen2_chopped.png dirtydozen.png
fi

create_part () {
    pdfjam $2 $3 $4 $5 $6 $7 $8 $9  --a4paper --width 20cm --outfile part$1_tmp1.pdf --delta '1cm 1cm'
    pdfjam part$1_tmp1.pdf 8,7,1,6,2,5,3,4 --a4paper --otheredge --outfile part$1_tmp2.pdf
    pdfjam part$1_tmp2.pdf --a4paper --nup 2x4 --angle 90 --outfile part$1_tmp3.pdf
    pdfcrop part$1_tmp3.pdf part$1_tmp4.pdf
    pdfjam part$1_tmp4.pdf --a4paper --trim '-0.5cm -0.5cm -0.5cm -0.5cm' --outfile part$1_tmp5.pdf
    pdfjam part$1_tmp5.pdf --a4paper --outfile part$1.pdf
}
create_cover () {
    magick convert -gravity NorthWest -pointsize 40 -undercolor white -annotate +0+0 'japanese jesus — part '$2' || https://triapul.cz/' $1 cover$2.png
}

echo "creating covers"
create_cover 000_jjc.png 1
create_cover 000_jjc.png 2
create_cover 015*.png 3

echo "creating pdf files (1/3)"
create_part 1 cover1.png $(ls 0*.png|head -n8|tail -n7)
create_part 2 cover2.png $(ls 0*.png|head -n15|tail -n7)
create_part 3 cover3.png $(ls 0*.png|tail -n7)

echo "joining pdf files (1/3)"
join_parts japanese_jesus.pdf


echo "creating pdf files (2/3)"
create_cover 000_jjc.png 3
create_part 1 cover1.png $(ls 0*.png|head -n8|tail -n7)
create_part 2 cover2.png $(ls 0*.png|head -n15|tail -n7)
create_part 3 cover3.png $(ls 0*.png|tail -n8|head -n7)

echo "joining pdf files (2/3)"
join_parts japanese_jesus_sans_constantine.pdf


echo "creating pdf files (3/3)"
create_part 1 cover1.png $(ls 0*.png|head -n8|tail -n7)
create_part 2 cover2.png 008*.png 009*.png 010*.png 011*.png dirtydozen.png 014*.png 015*.png
create_part 3 cover3.png $(ls 0*.png|tail -n7)

echo "joining pdf files (3/3)"
join_parts japanese_jesus_merged_dirty_dozen.pdf


echo "cleanup"
rm cover* *tmp*.pdf


echo "all done, enjoy japanese_jesus.pdf"
echo "see https://slrpnk.net/post/9615309 on folding"

top 20 comments
sorted by: hot top controversial new old
[–] tal@lemmy.today 4 points 1 day ago* (last edited 8 hours ago) (1 children)

A patch with a couple of changes you might want:

  • Support resuming downloads if interrupted (not that big a deal with how long this comic is).

  • Minimize duplication in the wget commands using a heredoc.

  • Fix command detection. As-written, the command detection doesn't appear to work for dash, which is the default /bin/sh on Debian. The sh string equality operator is = rather than ==, so changing it to that would be a minimal change, but POSIX also specifies a builtin test(1) operator for "is string null" (-z) and "is string non-null" (-n). https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html

fixes.patch


jj.sh 2026-06-30 19:00:48.185384533 -0700 +++ jj2.sh 2026-06-30 19:38:30.673920618 -0700 @@ -3,7 +3,7 @@ # create 3-part mini zine from japanese jesus

 check () {
-    if [ "$(which $1 2>/dev/null)" == "" ];
+    if [ -z "$(which $1 2>/dev/null)" ];
     then
         echo "ERROR: missing $1 utility"
         exit 1
@@ -21,37 +21,42 @@
     mv $1.tmp.png $1
 }

-if [ ! -f 000_jjc.png ];then
+if [ ! -f 022.png ];then
     echo "downloading source files"
-    wget https://img.triapul.cz/jjc.png -O 000_jjc.png
-    wget https://img.triapul.cz/christmas.png -O 001_christmas.png
-    wget https://img.triapul.cz/jordan_cold_cock.png -O 002_jordan_cold_cock.png
-    wget https://img.triapul.cz/40days1.png -O 003_40days1.png
-    wget https://img.triapul.cz/40days2.png -O 004_40days2.png
-    wget https://img.triapul.cz/third_oni.png -O 005_third_oni.png
-    wget https://img.triapul.cz/herod.png -O 006_herod.png
-    wget https://img.triapul.cz/mount_8.png -O 007_mount_8.png
-    wget https://img.triapul.cz/lazarus1.png -O 008_lazarus1.png
-    wget https://img.triapul.cz/danbrown.png -O 009_danbrown.png
-    wget https://img.triapul.cz/thread_the_needle.png -O 010_thread_the_needle.png
-    wget https://img.triapul.cz/thread_the_needle_2.png -O 011_thread_the_needle_2.png
-    wget https://img.triapul.cz/dirtydozen1.png -O 012_dirtydozen1.png
-    wget https://img.triapul.cz/dirtydozen2.png -O 013_dirtydozen2.png
-    wget https://img.triapul.cz/gethsemane.png -O 014_gethsemane.png
-    wget https://img.triapul.cz/pleased_to_meet_you.png -O 015_pleased_to_meet_you.png
-    wget https://img.triapul.cz/mrs_robinson.png -O 016_mrs_robinson.png
-    wget https://img.triapul.cz/vickers.png -O 017_vickers.png
-    wget https://img.triapul.cz/calvary.png -O 018_calvary.png
-    wget https://img.triapul.cz/judas.png -O 019_judas.png
-    wget https://img.triapul.cz/ghost_in_training.png -O 020_ghost_in_training.png
-    wget https://img.triapul.cz/fossberg.png -O 021_fossberg.png
-    wget https://img.triapul.cz/constantine.png -O 022_constantine.png
-
+    i=0
+    while read filename; do
+        wget -c "https://img.triapul.cz/$filename.png" -O $(printf %03d.png $i)
+        i=$(( $i + 1 ))
+    done <<EOF
+jjc
+christmas
+jordan_cold_cock
+40days1
+40days2
+third_oni
+herod
+mount_8
+lazarus1
+danbrown
+thread_the_needle
+thread_the_needle_2
+dirtydozen1
+dirtydozen2
+gethsemane
+pleased_to_meet_you
+mrs_robinson
+vickers
+calvary
+judas
+ghost_in_training
+fossberg
+constantine
+EOF

     echo "rotating images"
-    rotate 011*.png
-    rotate 012*.png
-    rotate 013*.png
+    rotate 011.png
+    rotate 012.png
+    rotate 013.png
 fi

 create_part () {
@@ -67,9 +72,9 @@
 }

 echo "creating covers"
-create_cover 000_jjc.png 1
-create_cover 000_jjc.png 2
-create_cover 015*.png 3
+create_cover 000.png 1
+create_cover 000.png 2
+create_cover 015.png 3

 echo "creating pdf files"
 create_part 1 cover1.png $(ls 0*.png|head -n8|tail -n7)

Apply with $ patch -p0 <fixes.patch, assuming that the script filename is jj.sh.

Also, I'm not sure whether you want to remove the downloaded PNG files or not. As things stand, the cleanup function in the script does not do this.

EDIT: Removed an extraneous ".png" from the wget command that I'd added into the patch in the comment without testing. You'd get "003.png.png" and such. Mea culpa.

Beware of bugs in the above code; I have only proved it correct, not tried it.


Donald Knuth

[–] django@discuss.tchncs.de 2 points 8 hours ago (1 children)

Thanks, i fixed the command detection in my second version. I don't know, if i will find the time to apply the rest to the new version.

[–] tal@lemmy.today 2 points 8 hours ago* (last edited 8 hours ago)

Sure. No obligation to use it, just throwing it out there if it might be of interest. Also fixed a problem in the patch where I'd modified the patch in the comment without retesting it. Sorry about that.

Thanks for making the script.

[–] lime@feddit.nu 5 points 1 day ago (2 children)

neat! heads up though, which is not standard posix. use realpath for portability.

[–] tal@lemmy.today 3 points 23 hours ago* (last edited 23 hours ago) (2 children)

You're right that realpath isn't in POSIX, but realpath doesn't do the same thing as which. @django@discuss.tchncs.de is using which to search $PATH.

He could maybe use type, which is similar, and is in POSIX.

https://pubs.opengroup.org/onlinepubs/9799919799/utilities/type.html

$ cd /tmp
$ which pdfjam
/usr/bin/pdfjam
$ type pdfjam
pdfjam is /usr/bin/pdfjam
$ realpath pdfjam
/tmp/pdfjam
$
[–] django@discuss.tchncs.de 3 points 21 hours ago

I am switching to command.

[–] lime@feddit.nu 3 points 23 hours ago (1 children)

doesn't realpath behave the same if a program is in $PATH? i thought it errored if it couldn't find a file.

[–] tal@lemmy.today 3 points 23 hours ago (1 children)

Nah. Doesn't look at $PATH at all.

$ realpath the-secret-to-life-the-universe-and-everything.txt
/tmp/the-secret-to-life-the-universe-and-everything.txt
$ echo $?
0
$ type the-secret-to-life-the-universe-and-everything.txt
the-secret-to-life-the-universe-and-everything.txt: not found
$ echo $?
127
$

It's for doing things like resolving symlinks, and even then, doesn't require that the target exist:

$ ln -s a b
$ realpath b
/tmp/a
$ echo $?
0
$
[–] lime@feddit.nu 3 points 22 hours ago

man, i must have hallucinated that manpage. i can't find it now.

[–] django@discuss.tchncs.de 4 points 1 day ago (1 children)

Thanks friend, I'll update it later from my computo.

[–] lime@feddit.nu 3 points 1 day ago (1 children)

i mean, considering you need a bunch of tools installed anyway it's probably not a big deal. not like someone is gonna run this on their headless storage vm running openindiana or anything.

[–] undthr@horp.sciops.net 5 points 1 day ago* (last edited 1 day ago) (1 children)

why do you have to single me out like that?

[–] django@discuss.tchncs.de 3 points 1 day ago

You can just download the pdf. ;-)

[–] pmjv 2 points 1 day ago* (last edited 1 day ago) (1 children)

i guess you could not include constantine, if you need the extra space for the cover -

or put the two dirty dozens together

http://triapul.cz/japanese_jesus/dirtydozen2.png

[–] django@discuss.tchncs.de 2 points 1 day ago (1 children)

thanks a lot for the suggestions, i'll try out both

[–] pmjv 1 points 1 day ago (1 children)

no problem! thanks for making this

[–] django@discuss.tchncs.de 2 points 8 hours ago (1 children)

I updated the post and added the two alternatives. Thanks for making this art.

[–] pmjv 2 points 7 hours ago
[–] undthr@horp.sciops.net 1 points 1 day ago
[–] pmjv 1 points 1 day ago