commit 4144570e4db9b1f5c7648a4b5caba0610ccc581d
parent 10748d5a616c274302ae0222c56d7e3a32c8d132
Author: ukai <ukai>
Date: Wed, 27 Nov 2002 16:46:30 +0000
[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 <hsaka@mth.biglobe.ne.jp>
Diffstat:
3 files changed, 36 insertions(+), 14 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,5 +1,13 @@
2002-11-28 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
+ * [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
+
+2002-11-28 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
+
* [w3m-dev 03496] parse <!-- ... --> in <script>
* etc.c (read_token): check <pre>
* file.c (HTMLlineproc0): remove comment processing
diff --git a/image.c b/image.c
@@ -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;
diff --git a/w3mimgdisplay.c b/w3mimgdisplay.c
@@ -13,6 +13,7 @@ static char *background = NULL;
static int offset_x = 0, offset_y = 0;
static int defined_bg = 0, defined_x = 0, defined_y = 0, defined_test = 0;
static int defined_debug = 0;
+static char *defined_size = NULL;
#define MAX_IMAGE 1000
static W3MImage *imageBuf = NULL;
@@ -63,6 +64,16 @@ main(int argc, char **argv)
exit(0);
}
+ if (defined_size) {
+ if (w_op->init(w_op)) {
+ W3MImage img;
+ int w, h;
+ if (w_op->get_image_size(w_op, &img, defined_size, &w, &h))
+ printf("%d %d\n", w, h);
+ }
+ exit(0);
+ }
+
w_op->set_background(w_op, background);
while (fgets(buf, sizeof(buf), stdin) != NULL) {
@@ -166,6 +177,11 @@ GetOption(int argc, char **argv)
else if (!strcmp("-test", argv[i])) {
defined_test = 1;
}
+ else if (!strcmp("-size", argv[i])) {
+ if (++i >= argc)
+ exit(1);
+ defined_size = argv[i];
+ }
else if (!strcmp("-debug", argv[i])) {
defined_debug = 1;
}