-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
197 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env bash | ||
|
||
#This script will merge two jpg images into one using imageMagick. | ||
#The final result will be a picture that is split diagonally. | ||
#The diagonal line will start from the top left of the image. | ||
#Both pictures must be of the same size. | ||
#If you do not give the filenames as part of the command line, the default names will be used (Left.jpg and Right.jpg). | ||
|
||
#If command line argument 1 is not provided, the value will default to the variable $LEFT_DEFAULT | ||
LEFT_DEFAULT="Left.jpg"; | ||
LEFT=${1:-$LEFT_DEFAULT}; | ||
|
||
#If command line argument 2 is not provided, the value will default to the variable $Right_DEFAULT | ||
RIGHT_DEFAULT="Right.jpg"; | ||
RIGHT=${2:-$RIGHT_DEFAULT}; | ||
|
||
#The intermediate images we will use must be png to support transparency. | ||
#We remove the extension '.jpg' from the filenames and add the extension '.png'. | ||
LEFT_OUT="${LEFT%.jpg}.Diagonal Down.png"; | ||
RIGHT_OUT="${RIGHT%.jpg}.Diagonal Down.png"; | ||
OUT="DiagonalDown.jpg"; | ||
OUT_PNG="DiagonalDown.png"; | ||
|
||
#Read the width of one of the images; | ||
WIDTH=`identify -format %w "$LEFT"`; | ||
#Read the height of one of the images; | ||
HEIGHT=`identify -format %h "$LEFT"`; | ||
|
||
OFFSET=1; | ||
WIDTH_M=$((WIDTH-OFFSET)); | ||
HEIGHT_M=$((HEIGHT-OFFSET)); | ||
|
||
#We create a transparent triangle on the side of the image we do not want visible. | ||
#A problem that arises here: we create a triangle with no fill, which turns black. Then we fill that area to make it transparent, since the image is a jpg some of the newly created black pixels do not get removed. When merging the two images, this creates a black diagonal line in the middle. | ||
magick "$LEFT" -gravity north -crop "$WIDTH"x"$HEIGHT"+0+0 +repage \ | ||
-draw "polygon 0,0 "$WIDTH","$HEIGHT" "$WIDTH",0 fill none alpha "$WIDTH_M","$OFFSET" floodfill" \ | ||
\( +clone -channel RGBA \) \ | ||
-compose DstOver -composite "$LEFT_OUT"; | ||
|
||
#We create a transparent triangle on the side of the image we do not want visible. | ||
magick "$RIGHT" -gravity north -crop "$WIDTH"x"$HEIGHT"+0+0 +repage \ | ||
-draw "polygon "$WIDTH","$HEIGHT" 0,0 0,"$HEIGHT" fill none alpha "$OFFSET","$HEIGHT_M" floodfill" \ | ||
\( +clone -channel RGBA \) \ | ||
-compose DstOver -composite "$RIGHT_OUT"; | ||
|
||
#We merge the two images together. | ||
composite -blend 50% "$LEFT_OUT" "$RIGHT_OUT" "$OUT"; | ||
|
||
#Cleaning up | ||
rm "$LEFT_OUT" "$RIGHT_OUT"; | ||
convert -define webp:lossless=true -quality 50 "$OUT" "$OUT_PNG" | ||
rm $OUT |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,119 @@ | ||
#!/usr/bin/env bash | ||
|
||
rm -rf app/src/test/snapshots/images ; ./gradlew recordPaparazziDebug && python3 organize_paparazzi_images.py | ||
# Constants | ||
SNAPSHOT_DIR="app/src/test/snapshots/images" | ||
RESULT_PNG="result.png" | ||
|
||
SCREENSHOT_FOLDER="app/src/test/snapshots/images/Pixel 8 Pro" | ||
SCREENSHOT_1="$SCREENSHOT_FOLDER/ca.amandeep.path.ui.main_MainScreenshotTest_screenshotMain[darkMode=true, device=Pixel 8 Pro, alertsExp=null, dirWarn=false, helpGuide=false, showOppoDir=false, showNotifs=true, updatedWhen=0 shortNames=false].png" | ||
SCREENSHOT_2="$SCREENSHOT_FOLDER/ca.amandeep.path.ui.main_MainScreenshotTest_screenshotMain[darkMode=false, device=Pixel 8 Pro, alertsExp=true, dirWarn=false, helpGuide=true, showOppoDir=false, showNotifs=true, updatedWhen=0 shortNames=false].png" | ||
SCREENSHOT_3_1="$SCREENSHOT_FOLDER/ca.amandeep.path.ui.main_MainScreenshotTest_screenshotMain[darkMode=true, device=Pixel 8 Pro, alertsExp=null, dirWarn=false, helpGuide=true, showOppoDir=true, showNotifs=true, updatedWhen=0 shortNames=false].png" | ||
SCREENSHOT_3_2="$SCREENSHOT_FOLDER/ca.amandeep.path.ui.main_MainScreenshotTest_screenshotMain[darkMode=false, device=Pixel 8 Pro, alertsExp=null, dirWarn=false, helpGuide=true, showOppoDir=true, showNotifs=true, updatedWhen=0 shortNames=false].png" | ||
SCREENSHOT_3="DiagonalDown.png" | ||
SCREENSHOT_4="$SCREENSHOT_FOLDER/ca.amandeep.path.ui.main_MainScreenshotTest_screenshotMain[darkMode=true, device=Pixel 8 Pro, alertsExp=false, dirWarn=false, helpGuide=true, showOppoDir=false, showNotifs=true, updatedWhen=0 shortNames=false].png" | ||
|
||
FRAME_1="frame1.webp" | ||
FRAME_2="frame2.webp" | ||
FRAME_3="frame3.webp" | ||
FRAME_4="frame4.webp" | ||
FRAMED_1="framescr1.webp" | ||
FRAMED_2="framescr2.webp" | ||
FRAMED_3="framescr3.webp" | ||
FRAMED_4="framescr4.webp" | ||
|
||
# Function to check if a command exists | ||
command_exists() { | ||
command -v "$1" &>/dev/null | ||
} | ||
|
||
# Verify all required commands are available | ||
for cmd in mogrify convert python3; do | ||
if ! command_exists "$cmd"; then | ||
echo "Error: '$cmd' is not available. Please install it and try again." | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "Preparing environment..." | ||
rm -rf "$SNAPSHOT_DIR" | ||
|
||
echo "Generating and organizing Paparazzi images..." | ||
if ! ./gradlew recordPaparazziDebug; then | ||
echo "Error during 'recordPaparazziDebug'. Please check your setup." | ||
exit 1 | ||
fi | ||
|
||
if ! python3 organize_paparazzi_images.py; then | ||
echo "Error during 'organize_paparazzi_images.py'. Please check the script." | ||
exit 1 | ||
fi | ||
|
||
echo "Trimming images..." | ||
for f in "$SCREENSHOT_1" "$SCREENSHOT_2" "$SCREENSHOT_3_1" "$SCREENSHOT_3_2" "$SCREENSHOT_4"; do | ||
if ! mogrify -trim +repage "$f"; then | ||
echo "Error trimming $f. Please check the image file and mogrify command." | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "Diagonalizing image..." | ||
rm -f "$SCREENSHOT_3" | ||
./diagonalCombine.sh "$SCREENSHOT_3_1" "$SCREENSHOT_3_2" | ||
|
||
echo "Framing images..." | ||
|
||
rm -f "$RESULT_PNG" | ||
if ! framer --oxipng-level 6 --pngquant-speed 1 "$FRAME_1" "$SCREENSHOT_1"; then | ||
echo "Error during image optimization. Please check 'framer' command." | ||
exit 1 | ||
fi | ||
rm -f "$FRAMED_1" | ||
if ! convert -define webp:lossless=true -quality 50 "$RESULT_PNG" "$FRAMED_1"; then | ||
echo "Error converting $RESULT_PNG to WebP format. Please check the 'convert' command." | ||
exit 1 | ||
fi | ||
rm -f "$RESULT_PNG" | ||
|
||
rm -f "$RESULT_PNG" | ||
if ! framer --oxipng-level 6 --pngquant-speed 1 "$FRAME_2" "$SCREENSHOT_2"; then | ||
echo "Error during image optimization. Please check 'framer' command." | ||
exit 1 | ||
fi | ||
rm -f "$FRAMED_2" | ||
if ! convert -define webp:lossless=true -quality 100 "$RESULT_PNG" "$FRAMED_2"; then | ||
echo "Error converting $RESULT_PNG to WebP format. Please check the 'convert' command." | ||
exit 1 | ||
fi | ||
rm -f "$RESULT_PNG" | ||
|
||
rm -f "$RESULT_PNG" | ||
if ! framer --oxipng-level 6 --pngquant-speed 1 "$FRAME_3" "$SCREENSHOT_3"; then | ||
echo "Error during image optimization. Please check 'framer' command." | ||
exit 1 | ||
fi | ||
rm -f "$FRAMED_3" | ||
if ! convert -define webp:lossless=true -quality 100 "$RESULT_PNG" "$FRAMED_3"; then | ||
echo "Error converting $RESULT_PNG to WebP format. Please check the 'convert' command." | ||
exit 1 | ||
fi | ||
rm -f "$RESULT_PNG" | ||
|
||
rm -f "$RESULT_PNG" | ||
if ! framer --oxipng-level 6 --pngquant-speed 1 "$FRAME_4" "$SCREENSHOT_4"; then | ||
echo "Error during image optimization. Please check 'framer' command." | ||
exit 1 | ||
fi | ||
rm -f "$FRAMED_4" | ||
if ! convert -define webp:lossless=true -quality 100 "$RESULT_PNG" "$FRAMED_4"; then | ||
echo "Error converting $RESULT_PNG to WebP format. Please check the 'convert' command." | ||
exit 1 | ||
fi | ||
rm -f "$RESULT_PNG" | ||
|
||
rm -f "$SCREENSHOT_3" | ||
|
||
for file in framescr*.webp; do convert "$file" "${file%.webp}.png"; done | ||
echo "Process completed successfully. Output file: $FRAMED_1" | ||
echo "Process completed successfully. Output file: $FRAMED_2" | ||
echo "Process completed successfully. Output file: $FRAMED_3" | ||
echo "Process completed successfully. Output file: $FRAMED_4" |
This file contains 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 characters