From 4daec3b7afe2dc55a5b20aab8cf11bf67ef8274e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Nov 2022 19:45:14 -0300 Subject: [PATCH 1/5] Update demo.yml --- .github/workflows/demo.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index d2a92e9..9601ced 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -3,7 +3,6 @@ on: push: branches: - main - - develop jobs: test-actions: runs-on: ubuntu-latest From ad50245421c038326d007626046d853d4d79cb34 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Nov 2022 21:17:01 -0300 Subject: [PATCH 2/5] Update entrypoint.sh --- entrypoint.sh | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 45c92f8..73dc8c6 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -11,30 +11,25 @@ outputFormats="jpeg|bmp|tiff|png|pdf|svg" # Echo with foreground color # $1 message; $2 red; $3 green; $4 blue -color() { - echo -e "\033[38;2;$2;$3;$4m$1\033[0m" -} +color() { echo -e "\033[38;2;$2;$3;$4m$1\033[0m"; } error() { color ":: Error :: $1" 255 0 0 exit 1 } -replace() { - echo $1 | sed -E "s/$2/$3/" -} +# Check if the `.eps` exists +if [[ ! -f $input ]]; then + error "Parameter \"input\" does not exist in \"$input\"" +fi + +replace() { echo $1 | sed -E "s/$2/$3/"; } # Change format # $1 path; $2 extension -changeFmt() { - local r=$(replace $1 '(.+\/)+(.+)\..+$' '\1\2') - echo "$r.$2" -} +changeFmt() { echo "$(replace $1 '(.+\/)+(.+)\..+$' '\1\2').$2"; } -removeFmt() { - local r=$(replace $1 '(.+\/)+(.+)\..+$' '\1\2') - echo "${r}$2" -} +removeFmt() { echo $(replace $1 '(.+\/)+(.+)\..+$' '\1\2'); } # Validates the $format input parameter isValidFormat() { @@ -43,11 +38,6 @@ isValidFormat() { fi } -# Check if the `.eps` exists -if [ ! -f $input ]; then - error "Parameter \"input\" does not exist in \"$input\"" -fi - isValidFormat $format defaultFilename=$(replace $input '(.+\/)+(.+)\.eps$' '\2') @@ -81,14 +71,14 @@ if [[ $format == +(jpeg|tiff|png|pdf|svg) ]]; then output=$(changeFmt $output "pdf") else device="bmp16m" - isRaster="-dGraphicsAlphaBits=4" + isBMP="-dGraphicsAlphaBits=4" fi dirOutput=$(replace $output '(.+\/).+$' '\1') if [ ! -d $dirOutput ]; then mkdir -p $dirOutput; fi -gs $isRaster -sDEVICE=$device -dEPSCrop -o $output -q $input +gs $isBMP -sDEVICE=$device -dEPSCrop -o $output -q $input if [[ $toCairo ]]; then input=$output @@ -102,12 +92,13 @@ if [[ $toCairo ]]; then pdftocairo -singlefile -$fmt -transp $input $output;; jpeg) output=$(removeFmt $input); - pdftocairo -singlefile -$fmt -jpegopt quality=100,optimize=y $input $output;; + pdftocairo -singlefile -$fmt -jpegopt quality=100,optimize=y $input $output + wait + mv "$output.jpg" "$output.jpeg";; esac wait - if [[ $fmt == "jpeg" ]]; then mv "$output.jpg" "$output.jpeg"; fi if [[ $fmt == "tiff" ]]; then mv "$output.tif" "$output.tiff"; fi if [[ $fmt == +(png|jpeg|tiff) ]]; then output="$output.$fmt"; fi From 0e8012a7ce23dc1cab19aeb91bbc8aa599f405bb Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Nov 2022 21:45:46 -0300 Subject: [PATCH 3/5] Add support to PostScript --- entrypoint.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 73dc8c6..e06410c 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,7 +7,7 @@ input="$1" output="$2" format="$3" -outputFormats="jpeg|bmp|tiff|png|pdf|svg" +outputFormats="jpeg|bmp|tiff|png|pdf|svg|ps" # Echo with foreground color # $1 message; $2 red; $3 green; $4 blue @@ -62,9 +62,9 @@ case $output in format=$defaultOutputFormat;; esac -if [[ $format == +(jpeg|tiff|png|svg) ]]; then toCairo=true; fi +if [[ $format == +(jpeg|tiff|png|svg|ps) ]]; then toCairo=true; fi -if [[ $format == +(jpeg|tiff|png|pdf|svg) ]]; then +if [[ $format == +(jpeg|tiff|png|pdf|svg|ps) ]]; then device="pdfwrite" fmt=$format format="pdf" @@ -84,9 +84,9 @@ if [[ $toCairo ]]; then input=$output case $fmt in - svg) - output=$(changeFmt $input "svg") - pdftocairo -svg $input $output;; + +(svg|ps)) + output=$(changeFmt $input $fmt) + pdftocairo -$fmt $input $output;; +(png|tiff)) output=$(removeFmt $input); pdftocairo -singlefile -$fmt -transp $input $output;; From 18c409f78692818d309870c24f277b1df1a7f97e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Nov 2022 22:13:52 -0300 Subject: [PATCH 4/5] Add docs PS support --- .github/workflows/demo.yml | 9 +++++++++ README.md | 6 +++--- action.yml | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index 9601ced..b06b8cb 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -3,6 +3,7 @@ on: push: branches: - main + - develop jobs: test-actions: runs-on: ubuntu-latest @@ -63,3 +64,11 @@ jobs: output: ./logo6 # The path will be converted to "./logo6.pdf" format: pdf + - name: Convert EPS to PS with "input" and "format" defined, but with incomplete "output" + if: success() + uses: ./ + with: + input: ./.github/workflows/logo.eps + output: ./logo7 # The path will be converted to "./logo7.ps" + format: ps + diff --git a/README.md b/README.md index b45e514..282d630 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ - **Vector formats** - `.svg` + - `.ps` - `.pdf` ## Usage @@ -52,11 +53,10 @@ format: # Optional. Path to the output file. # Patterns: "" | "./" | "./dirname/" | "./filename" | "./filename.xyz" - # ".xyz" = supported formats - output: ./pathTo/outputFilename.xyz + output: ./pathTo/outputFilename # Optional. Format of the output file. - # Options: "png" | "bmp" | "tiff" | "jpeg" | "svg" | "pdf" + # Options: "png" | "bmp" | "tiff" | "jpeg" | "svg" | "ps" | "pdf" format: png ``` --- diff --git a/action.yml b/action.yml index 8f883ab..d171345 100644 --- a/action.yml +++ b/action.yml @@ -1,6 +1,6 @@ name: EPS 2 Image author: lunatic-fox -description: Convert an EPS file to Image formats (PNG, JPEG, TIFF or BMP) or to Vector formats (SVG or PDF). +description: Convert an EPS file to Image formats (PNG, JPEG, TIFF or BMP) or to Vector formats (SVG, PS or PDF). inputs: input: From 5af222f8b1913e3abd1ec6354464b12b05ae52ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9lio=20J=C3=BAnior?= <76992016+lunatic-fox@users.noreply.github.com> Date: Wed, 16 Nov 2022 22:18:57 -0300 Subject: [PATCH 5/5] Update demo.yml --- .github/workflows/demo.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index b06b8cb..65e9615 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -3,7 +3,6 @@ on: push: branches: - main - - develop jobs: test-actions: runs-on: ubuntu-latest