From 93073107389ae6612068af8b99217c90c87e8612 Mon Sep 17 00:00:00 2001 From: Fumitoshi UKAI Date: Wed, 27 Nov 2002 16:46:30 +0000 Subject: [w3m-dev 03497] incorrect image size * image.c (getImageSize): invoke w3mimgdiplay -size instead of "5;..." * w3mimgdisplay.c (defined_size): added (main): if defined_size get_image_size() (GetOption): -size From: Hironori SAKAMOTO --- image.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'image.c') diff --git a/image.c b/image.c index e2aaeaa..c2873a8 100644 --- a/image.c +++ b/image.c @@ -1,4 +1,4 @@ -/* $Id: image.c,v 1.20 2002/11/24 16:02:22 ukai Exp $ */ +/* $Id: image.c,v 1.21 2002/11/27 16:46:34 ukai Exp $ */ #include "fm.h" #include @@ -589,6 +589,7 @@ int getImageSize(ImageCache * cache) { Str tmp; + FILE *f; int w = 0, h = 0; if (!activeImage) @@ -597,21 +598,18 @@ getImageSize(ImageCache * cache) (cache->width > 0 && cache->height > 0)) return FALSE; tmp = Strnew(); - if (!(Imgdisplay_rf && Imgdisplay_wf)) { - if (!openImgdisplay()) - return FALSE; - } - fputs("5;", Imgdisplay_wf); /* Get Size */ - fputs(cache->file, Imgdisplay_wf); - fputs("\n", Imgdisplay_wf); - fflush(Imgdisplay_wf); - { - char buf[1024]; - fgets(buf, sizeof(buf), Imgdisplay_rf); - if (sscanf(buf, "%d %d", &w, &h) != 2) { - return FALSE; - } + if (!strchr(Imgdisplay, '/')) + Strcat_m_charp(tmp, w3m_auxbin_dir(), "/", NULL); + Strcat_m_charp(tmp, Imgdisplay, " -size ", shell_quote(cache->file), + " 2> /dev/null", NULL); + f = popen(tmp->ptr, "r"); + if (!f) + return FALSE; + while (fscanf(f, "%d %d", &w, &h) < 0) { + if (feof(f)) + break; } + pclose(f); if (!(w > 0 && h > 0)) return FALSE; -- cgit v1.2.3