This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository legacy-imlib2.
View the commit online.
commit d22357e56c34d00abeb4efb0e7256e89c08ada16
Author: Kim Woelders <k...@woelders.dk>
AuthorDate: Fri Dec 13 10:58:10 2024 +0100
imlib2_conv: Optionally produce scaled image
---
src/bin/imlib2_conv.c | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/src/bin/imlib2_conv.c b/src/bin/imlib2_conv.c
index e0edeb9..5dc3004 100644
--- a/src/bin/imlib2_conv.c
+++ b/src/bin/imlib2_conv.c
@@ -31,7 +31,8 @@
"OPTIONS:\n" \
" -h : Show this help\n" \
" -i key=value : Attach tag with integer value for saver\n" \
- " -j key=string : Attach tag with string value for saver\n"
+ " -j key=string : Attach tag with string value for saver\n" \
+ " -g WxH : Specify output image size\n"
static void
usage(void)
@@ -81,6 +82,7 @@ main(int argc, char **argv)
{
int opt, err;
const char *fin, *fout;
+ int wo, ho;
char *dot;
Imlib_Image im;
int cnt, save_cnt;
@@ -88,11 +90,12 @@ main(int argc, char **argv)
unsigned int t0;
double dt;
+ wo = ho = 0;
show_time = false;
save_cnt = 1;
t0 = 0;
- while ((opt = getopt(argc, argv, "hi:j:n:")) != -1)
+ while ((opt = getopt(argc, argv, "hi:j:g:n:")) != -1)
{
switch (opt)
{
@@ -103,6 +106,9 @@ main(int argc, char **argv)
case 'i':
case 'j':
break; /* Ignore this time around */
+ case 'g':
+ sscanf(optarg, "%ux%u", &wo, &ho);
+ break;
case 'n':
save_cnt = atoi(optarg);
show_time = true;
@@ -130,9 +136,27 @@ main(int argc, char **argv)
Dprintf("%s: im=%p\n", __func__, im);
imlib_context_set_image(im);
+ if (wo != 0 || ho != 0)
+ {
+ Imlib_Image im2;
+ int wi, hi;
+ wi = imlib_image_get_width();
+ hi = imlib_image_get_height();
+ im2 = imlib_create_cropped_scaled_image(0, 0, wi, hi, wo, ho);
+ if (!im2)
+ {
+ fprintf(stderr, "*** Error: Failed to scale image\n");
+ return 1;
+ }
+#if DEBUG
+ imlib_free_image_and_decache();
+#endif
+ imlib_context_set_image(im2);
+ }
+
/* Re-parse options to attach parameters to be used by savers */
optind = 1;
- while ((opt = getopt(argc, argv, "hi:j:n:")) != -1)
+ while ((opt = getopt(argc, argv, "hi:j:g:n:")) != -1)
{
switch (opt)
{
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.