Last active
March 25, 2025 05:01
-
-
Save irfnrdh/ed3f5db0392b785e1a6a77a331473d35 to your computer and use it in GitHub Desktop.
Revisions
-
irfnrdh revised this gist
Mar 25, 2025 . 1 changed file with 10 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,6 +29,9 @@ X_OFFSET_RIGHT=$((X_OFFSET_LEFT + WIDTH + GAP)) # Posisi gambar kedua (kanan) IMAGES=("$INPUT_DIR"/*.{jpg,jpeg,png}) TOTAL_IMAGES=${#IMAGES[@]} # Array untuk menampung nama file yang akan dijadikan PDF PDF_FILES=() # Proses gambar per pasangan (foto 1 dan foto 2 untuk satu kertas) for ((i=0; i<TOTAL_IMAGES; i+=2)); do # Ambil dua gambar untuk setiap kertas @@ -52,6 +55,12 @@ for ((i=0; i<TOTAL_IMAGES; i+=2)); do # Menambahkan penamaan file yang diurutkan mv "$OUTPUT_DIR/${FILENAME}_A4_landscape_with_gap.jpg" "$OUTPUT_DIR/Page_$((i / 2 + 1)).jpg" # Menambahkan file gambar ke array PDF PDF_FILES+=("$OUTPUT_DIR/Page_$((i / 2 + 1)).jpg") done # Menggabungkan semua gambar menjadi satu PDF convert "${PDF_FILES[@]}" "$OUTPUT_DIR/output.pdf" echo "Proses selesai! PDF siap untuk dicetak: $OUTPUT_DIR/output.pdf" -
irfnrdh revised this gist
Mar 25, 2025 . 1 changed file with 27 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,21 +25,33 @@ Y_OFFSET=$(( (A4_HEIGHT - HEIGHT) / 2 )) # Posisi vertikal untuk kedua gambar ( X_OFFSET_RIGHT=$((X_OFFSET_LEFT + WIDTH + GAP)) # Posisi gambar kedua (kanan) # Menyiapkan array untuk gambar-gambar yang ada IMAGES=("$INPUT_DIR"/*.{jpg,jpeg,png}) TOTAL_IMAGES=${#IMAGES[@]} # Proses gambar per pasangan (foto 1 dan foto 2 untuk satu kertas) for ((i=0; i<TOTAL_IMAGES; i+=2)); do # Ambil dua gambar untuk setiap kertas IMAGE1="${IMAGES[$i]}" IMAGE2="${IMAGES[$((i+1))]}" # Nama file tanpa ekstensi BASENAME1=$(basename "$IMAGE1") BASENAME2=$(basename "$IMAGE2") FILENAME="${BASENAME1%.*}_${BASENAME2%.*}" # Membuat gambar 5R dari setiap foto convert "$IMAGE1" -resize ${WIDTH}x${HEIGHT}\! "$OUTPUT_DIR/${FILENAME}_5R_1.jpg" convert "$IMAGE2" -resize ${WIDTH}x${HEIGHT}\! "$OUTPUT_DIR/${FILENAME}_5R_2.jpg" # Menempatkan dua gambar pada satu halaman A4 dengan padding dan gap, orientasi landscape convert -size ${A4_WIDTH}x${A4_HEIGHT} xc:white \ "$OUTPUT_DIR/${FILENAME}_5R_1.jpg" -geometry +${X_OFFSET_LEFT}+${Y_OFFSET} -composite \ "$OUTPUT_DIR/${FILENAME}_5R_2.jpg" -geometry +${X_OFFSET_RIGHT}+${Y_OFFSET} -composite \ "$OUTPUT_DIR/${FILENAME}_A4_landscape_with_gap.jpg" # Menambahkan penamaan file yang diurutkan mv "$OUTPUT_DIR/${FILENAME}_A4_landscape_with_gap.jpg" "$OUTPUT_DIR/Page_$((i / 2 + 1)).jpg" done echo "Proses selesai!" -
irfnrdh revised this gist
Mar 25, 2025 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,8 +12,8 @@ WIDTH=1500 # 5 inci = 1500 piksel (300 DPI) HEIGHT=2100 # 7 inci = 2100 piksel (300 DPI) # Ukuran A4 dalam piksel (untuk resolusi 300 DPI) A4_WIDTH=3508 # 11.69 inci = 3508 piksel (300 DPI) A4_HEIGHT=2550 # 8.27 inci = 2550 piksel (300 DPI) # Padding di sekitar gambar dan kertas (dalam piksel) PADDING=150 # 0.5 inci padding (300 DPI) @@ -34,11 +34,11 @@ for IMAGE in "$INPUT_DIR"/*.{jpg,jpeg,png}; do # Membuat gambar 5R convert "$IMAGE" -resize ${WIDTH}x${HEIGHT}\! "$OUTPUT_DIR/${BASENAME}_5R.jpg" # Menempatkan dua gambar pada satu halaman A4 dengan padding dan gap, orientasi landscape convert -size ${A4_WIDTH}x${A4_HEIGHT} xc:white \ "$OUTPUT_DIR/${BASENAME}_5R.jpg" -geometry +${X_OFFSET_LEFT}+${Y_OFFSET} -composite \ "$OUTPUT_DIR/${BASENAME}_5R.jpg" -geometry +${X_OFFSET_RIGHT}+${Y_OFFSET} -composite \ "$OUTPUT_DIR/${BASENAME}_A4_landscape_with_gap.jpg" fi done -
irfnrdh revised this gist
Mar 25, 2025 . 1 changed file with 10 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,19 +15,15 @@ HEIGHT=2100 # 7 inci = 2100 piksel (300 DPI) A4_WIDTH=2550 # 8.27 inci = 2550 piksel (300 DPI) A4_HEIGHT=3508 # 11.69 inci = 3508 piksel (300 DPI) # Padding di sekitar gambar dan kertas (dalam piksel) PADDING=150 # 0.5 inci padding (300 DPI) GAP=150 # 0.5 inci gap di antara gambar (300 DPI) # Posisi gambar pertama dan kedua X_OFFSET_LEFT=$(( (A4_WIDTH - WIDTH - GAP - WIDTH) / 2 )) # Posisi gambar pertama (kiri) Y_OFFSET=$(( (A4_HEIGHT - HEIGHT) / 2 )) # Posisi vertikal untuk kedua gambar (ditengah) X_OFFSET_RIGHT=$((X_OFFSET_LEFT + WIDTH + GAP)) # Posisi gambar kedua (kanan) for IMAGE in "$INPUT_DIR"/*.{jpg,jpeg,png}; do if [ -f "$IMAGE" ]; then @@ -38,11 +34,11 @@ for IMAGE in "$INPUT_DIR"/*.{jpg,jpeg,png}; do # Membuat gambar 5R convert "$IMAGE" -resize ${WIDTH}x${HEIGHT}\! "$OUTPUT_DIR/${BASENAME}_5R.jpg" # Menempatkan dua gambar pada satu halaman A4 dengan padding dan gap convert -size ${A4_WIDTH}x${A4_HEIGHT} xc:white \ "$OUTPUT_DIR/${BASENAME}_5R.jpg" -geometry +${X_OFFSET_LEFT}+${Y_OFFSET} -composite \ "$OUTPUT_DIR/${BASENAME}_5R.jpg" -geometry +${X_OFFSET_RIGHT}+${Y_OFFSET} -composite \ "$OUTPUT_DIR/${BASENAME}_A4_with_gap.jpg" fi done -
irfnrdh revised this gist
Mar 25, 2025 . 1 changed file with 18 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,11 +15,19 @@ HEIGHT=2100 # 7 inci = 2100 piksel (300 DPI) A4_WIDTH=2550 # 8.27 inci = 2550 piksel (300 DPI) A4_HEIGHT=3508 # 11.69 inci = 3508 piksel (300 DPI) # Padding di sekitar gambar (dalam piksel) PADDING=150 # 0.5 inci padding (300 DPI) # Ukuran area yang tersedia untuk gambar dengan padding AVAILABLE_WIDTH=$((A4_WIDTH - 2 * PADDING)) AVAILABLE_HEIGHT=$((A4_HEIGHT - 2 * PADDING)) # Memastikan dua gambar muat dalam satu A4 # Setiap gambar akan diposisikan di kiri dan kanan dengan jarak padding X_OFFSET_LEFT=$PADDING Y_OFFSET_LEFT=$PADDING X_OFFSET_RIGHT=$((PADDING + WIDTH)) Y_OFFSET_RIGHT=$PADDING for IMAGE in "$INPUT_DIR"/*.{jpg,jpeg,png}; do if [ -f "$IMAGE" ]; then @@ -30,14 +38,11 @@ for IMAGE in "$INPUT_DIR"/*.{jpg,jpeg,png}; do # Membuat gambar 5R convert "$IMAGE" -resize ${WIDTH}x${HEIGHT}\! "$OUTPUT_DIR/${BASENAME}_5R.jpg" # Menempatkan dua gambar pada satu halaman A4 dengan padding convert -size ${A4_WIDTH}x${A4_HEIGHT} xc:white \ "$OUTPUT_DIR/${BASENAME}_5R.jpg" -geometry +${X_OFFSET_LEFT}+${Y_OFFSET_LEFT} -composite \ "$OUTPUT_DIR/${BASENAME}_5R.jpg" -geometry +${X_OFFSET_RIGHT}+${Y_OFFSET_RIGHT} -composite \ "$OUTPUT_DIR/${BASENAME}_A4_with_padding.jpg" fi done -
irfnrdh created this gist
Mar 25, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ #!/bin/bash # Direktori tempat gambar-gambar disimpan INPUT_DIR="input" # Ganti dengan direktori input gambar OUTPUT_DIR="output" # Ganti dengan direktori output untuk gambar yang sudah diubah # Membuat direktori output jika belum ada mkdir -p "$OUTPUT_DIR" # Ukuran 5R dalam piksel (untuk resolusi 300 DPI) WIDTH=1500 # 5 inci = 1500 piksel (300 DPI) HEIGHT=2100 # 7 inci = 2100 piksel (300 DPI) # Ukuran A4 dalam piksel (untuk resolusi 300 DPI) A4_WIDTH=2550 # 8.27 inci = 2550 piksel (300 DPI) A4_HEIGHT=3508 # 11.69 inci = 3508 piksel (300 DPI) # Menyiapkan posisi untuk dua gambar (kiri dan kanan) X_OFFSET_LEFT=0 Y_OFFSET_LEFT=0 X_OFFSET_RIGHT=1500 # Gambar kedua akan dimulai setelah gambar pertama (1500 piksel) Y_OFFSET_RIGHT=0 for IMAGE in "$INPUT_DIR"/*.{jpg,jpeg,png}; do if [ -f "$IMAGE" ]; then # Nama file tanpa ekstensi FILENAME=$(basename "$IMAGE") BASENAME="${FILENAME%.*}" # Membuat gambar 5R convert "$IMAGE" -resize ${WIDTH}x${HEIGHT}\! "$OUTPUT_DIR/${BASENAME}_5R.jpg" # Menyiapkan dua gambar pada kertas A4 (dua gambar pada satu halaman A4) convert "$OUTPUT_DIR/${BASENAME}_5R.jpg" "$OUTPUT_DIR/${BASENAME}_5R.jpg" +append -resize ${A4_WIDTH}x${A4_HEIGHT}\! -page +0+0 "$OUTPUT_DIR/${BASENAME}_A4.jpg" # Posisi gambar pertama (di kiri) convert "$OUTPUT_DIR/${BASENAME}_5R.jpg" -resize ${WIDTH}x${HEIGHT}\! -geometry +${X_OFFSET_LEFT}+${Y_OFFSET_LEFT} -composite "$OUTPUT_DIR/${BASENAME}_A4.png" # Posisi gambar kedua (di kanan) convert "$OUTPUT_DIR/${BASENAME}_5R.jpg" -resize ${WIDTH}x${HEIGHT}\! -geometry +${X_OFFSET_RIGHT}+${Y_OFFSET_RIGHT} -composite "$OUTPUT_DIR/${BASENAME}_A4.png" fi done echo "Proses selesai!"