Author Topic: Getting image properties  (Read 565 times)

Offline EelkoGielis

  • Newcomer
  • Posts: 16
    • View Profile
    • Flickr Astro set
Getting image properties
« on: 2018 May 12 11:58:38 »
Hi,

How do I get the image properties of an active view?

I can get the name of the view in a dialog, but width and height are not possible. I searched some sample codes and this section of Development to no avail or it is getting so old I am not sure it is still vallid.

To get you started, I have the next code:

Code: [Select]
#include <pjsr/FrameStyle.jsh>
#include <pjsr/Sizer.jsh>

function IP_dialog() {
    this.__base__ = Dialog;
    this.__base__();

    // Active image
    var pwindow   = ImageWindow.activeWindow;
    var pWindowId = pwindow.mainView.id;

    // image info label
    this.img_infoLabel = new Label (this);
    with (this.img_infoLabel) {
        frameStyle = FrameStyle_Box;
        margin = 4;
        wordWrapping = true;
        useRichText = true;
        text = "<b>"+pWindowId+"</b> <br>" +
            "Width : " +pWindowId.width+ "<br>"+
            "Height: " +pWindowId.height+ "<br>"+
            "GS/C  : " +pWindowId.color;
        }

    // buttons
    this.cancel_Button = new PushButton (this);
    this.cancel_Button.text = " Cancel ";
    this.cancel_Button.onClick = function() { this.dialog.cancel(); };

    this.buttons_Sizer = new HorizontalSizer;
    this.buttons_Sizer.spacing = 4;
    this.buttons_Sizer.addStretch();
    this.buttons_Sizer.add (this.cancel_Button);

    // pack everything
    this.sizer = new VerticalSizer;
    with (this.sizer) {
        margin = 6;
        spacing = 6;
        add (this.img_infoLabel);
        addSpacing (4);
        add (this.buttons_Sizer);
    }
}
AS_dialog.prototype = new Dialog;

function main() {
    var dialog = new AS_dialog;   // has to be done after settings are loaded
    if (!dialog.execute()) {
        return;
    }
}

main();

And this gives an undefined property of the (at least) 2 most important questions.
Celestron 9,25" Edge HD, SkyWatcher NEQ6Pro, Lacerta MGEN on F500mm f90mm APO