POV-Ray : Newsgroups : povray.general : Image resolution Server Time
28 Nov 2024 19:39:31 EST (-0500)
  Image resolution (Message 1 to 7 of 7)  
From: Trevor G Quayle
Subject: Image resolution
Date: 15 Sep 2006 08:25:00
Message: <web.450a9b3bebe8c5f4c150d4c10@news.povray.org>
Does anyone know of a way to automatically detect the resolution of an input
image in POV?

-tgq


Post a reply to this message

From: Marc
Subject: Re: Image resolution
Date: 15 Sep 2006 08:46:19
Message: <450aa09b$1@news.povray.org>

news: web.450a9b3bebe8c5f4c150d4c10@news.povray.org...
> Does anyone know of a way to automatically detect the resolution of an
input
> image in POV?
>
> -tgq
I asked the same question some times ago
I got no positive answer... It looks like there is no simple way to do that.
I wish someone  tell me I'm wrong :-)

Marc


Post a reply to this message

From: Warp
Subject: Re: Image resolution
Date: 15 Sep 2006 11:28:08
Message: <450ac688@news.povray.org>
Trevor G Quayle <Tin### [at] hotmailcom> wrote:
> Does anyone know of a way to automatically detect the resolution of an input
> image in POV?

  No.

-- 
                                                          - Warp


Post a reply to this message

From: Trevor G Quayle
Subject: Re: Image resolution
Date: 15 Sep 2006 12:25:01
Message: <web.450ad2fbdb36c48c150d4c10@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> Trevor G Quayle <Tin### [at] hotmailcom> wrote:
> > Does anyone know of a way to automatically detect the resolution of an input
> > image in POV?
>
>   No.
>
> --
>                                                           - Warp

Too bad.  However, I suppose that it can be done through source code, as it
seems heightfields are aware of the image size.

-tgq


Post a reply to this message

From: Eero Ahonen
Subject: Re: Image resolution
Date: 15 Sep 2006 12:39:17
Message: <450ad735$1@news.povray.org>
Trevor G Quayle wrote:
> Does anyone know of a way to automatically detect the resolution of an input
> image in POV?
> 
> -tgq

With external scripting:

sed -e 's/input_image_width/`imgsize input_image.jpg |cut -d "\"" -f
2`/g' -e 's/input_image_height/`imgsize input_image.jpg |cut -d "\"" -f
4`/g' file.pov >file2.pov && povray +Ifile2.pov

Requires imgsize to be installed - comes with dev-perl/ImageSize in case
of Gentoo.

-- 
Eero "Aero" Ahonen
   http://www.zbxt.net
      aer### [at] removethiszbxtnetinvalid


Post a reply to this message

From: Warp
Subject: Re: Image resolution
Date: 15 Sep 2006 22:11:55
Message: <450b5d6b@news.povray.org>
Eero Ahonen <aer### [at] removethiszbxtnetinvalid> wrote:
> sed -e 's/input_image_width/`imgsize input_image.jpg |cut -d "\"" -f
> 2`/g' -e 's/input_image_height/`imgsize input_image.jpg |cut -d "\"" -f
> 4`/g' file.pov >file2.pov && povray +Ifile2.pov

  It would be easier to just use the command-line parameter:
Declare=input_image_width=`whatever`

-- 
                                                          - Warp


Post a reply to this message

From: Tim Attwood
Subject: Re: Image resolution
Date: 16 Sep 2006 04:22:35
Message: <450bb44b$1@news.povray.org>
>  It would be easier to just use the command-line parameter:

There's often easier ways... like looking at the image size
in an editor.

A built-in function for this would be handy...

The file_image_size macro tries to measure the pixel width
by sampling at random for a point that differs in color from
it's neighbors. Not all images have such points, so this
can fail to report the proper sizes on low-color images.

#include "strings.inc"
#include "math.inc"

// internal macro for file_image_size
#macro seek(point, dist)
      #local rez = dist*0.1;
      #local RP_COLOR = _IMF(point.x, point.y, point.z);
      #local seekcount = 0;
      #local seekf = true;
      #local last = point;
      #while (seekf & (seekcount<11))
         #local seekcount = seekcount + 1;
         #local samp = point+seekcount*rez;
         #local TEMP_COLOR = _IMF(samp.x,samp.y,samp.z);
         #local seekf = VEq5D(RP_COLOR, TEMP_COLOR);
         #if (seekf) #local last = samp; #end
      #end
      #local zed = 0.00001; // desired accuracy
      #if ((abs(rez.x)>zed)|(abs(rez.y)>zed)|(abs(rez.z)>zed))
         #local result = seek(last, rez);
      #else
         #local result = samp;
      #end
      (result)
#end

// returns a 2D vector with the image size
// Usage: (string, string, float)
// itype = the image type
// iname = the file name
// num = the number of samples
// Example: #local G1 = file_image_size("png", "plasma3.png", 12);
#macro file_image_size(itype, iname, num)
   #local SI = "#declare _IMF = function {\n";
   #local SI = concat(SI, "pigment {\n");
   #local SI = concat(SI, "image_map {\n");
   #local SI = concat(SI, itype," \"",iname,"\"\n");
   #local SI = concat(SI, "map_type 0\n");
   #local SI = concat(SI, "once}scale 1000000}};\n");
   Parse_String(SI)
   #local S = seed(num);
   #local DX = 1000000;
   #local DY = 1000000;
   #local C = 0;
   #while (C < num)
      // a random point
      #local RP = <rand(S)*1000000,rand(S)*1000000,0>;
      #local temp = seek(RP, <DX,0,0>);
      #local xright = temp.x;
      #local temp = seek(RP, <-DX,0,0>);
      #local xleft = temp.x;
      #local temp = seek(RP, <0,DY,0>);
      #local yup = temp.y;
      #local temp = seek(RP, <0,-DY,0>);
      #local ydown = temp.y;
      // found
      #local found_DX = (xright-xleft);
      #local found_DY = (yup-ydown);
      // adjust pixel size guess
      #local DX = min(DX,found_DX);
      #local DY = min(DY,found_DY);
      #local C = C + 1;
   #end
   #undef _IMF
   #local result = <int((1/DX)*1000000+0.9999), int((1/DY)*1000000+0.9999)>;
   (result)
#end


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.