Files
Chi-Wei Lee 751f9448a8 Keep the directory when mogrify -format reads a compressed file (#8988)
GetPathComponent() with BasePathSansCompressExtension kept the
directory for an uncompressed file but returned only the base name for
a file ending in .gz, .bz2, .Z, .svgz or .wmz. mogrify -format uses
this path to name its output, so "mogrify -format bmp dir/image.ppm.gz"
wrote image.bmp into the current directory instead of dir/image.bmp.

Strip only the compression extension so the directory is kept.
2026-09-29 11:29:49 -04:00

41 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
#
# Copyright 1999 ImageMagick Studio LLC, a non-profit organization
# dedicated to making software imaging solutions freely available.
#
# You may not use this file except in compliance with the License. You may
# obtain a copy of the License at
#
# https://imagemagick.org/license/
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Regression tests for mogrify.
#
. ./common.shi
. ${srcdir}/tests/common.shi
echo "1..2"
dir=mogrify_format_dir
rm -rf "$dir" mogrify_format_plain.bmp mogrify_format_gzip.bmp
mkdir "$dir" || exit 1
# -format writes the new file next to the input.
${MAGICK} -size 2x2 xc:red "$dir/mogrify_format_plain.ppm" && \
${MAGICK} mogrify -format bmp "$dir/mogrify_format_plain.ppm" && \
[ -f "$dir/mogrify_format_plain.bmp" ] && \
[ ! -f mogrify_format_plain.bmp ] && echo "ok" || echo "not ok"
# The same holds when the input carries a compression extension.
${MAGICK} -size 2x2 xc:red "$dir/mogrify_format_gzip.ppm.gz" && \
${MAGICK} mogrify -format bmp "$dir/mogrify_format_gzip.ppm.gz" && \
[ -f "$dir/mogrify_format_gzip.bmp" ] && \
[ ! -f mogrify_format_gzip.bmp ] && echo "ok" || echo "not ok"
rm -rf "$dir" mogrify_format_plain.bmp mogrify_format_gzip.bmp
: