Mediaget/getimage

I have the following stored procedure to get images from the database to into my asp.
PROCEDURE GETIMAGE (
ord_procedure_path in varchar2,
http_if_modified_since in varchar2,
http_status out varchar2,
http_last_modified out varchar2,
http_redirect out varchar2,
ord_content_type out varchar2,
ord_content_length out number,
ord_content_blob out blob,
ord_content_bfile out bfile
as
localImage ordsys.ordimage;
begin
* Retrieve the image object from the database into a local object.
select IMAGE into localImage from PD_UPLOAD_IMAGE where SEQ = ord_procedure_path;
* Figure out the status of the client's cache. If the client's cache
* is up to date, then we can return immediately.
http_status := ordwebutl.cache_status( localImage.getUpdateTime(),
http_if_modified_since,
http_last_modified );
if http_status = 304 then
return;
end if;
* Figure out where the image is.
if localImage.isLocal() then
* The image is stored locally in the localData BLOB attribute
ord_content_type := localImage.getMimeType();
ord_content_length := localImage.getContentLength();
ord_content_blob := localImage.getContent();
elsif upper( localImage.getSourceType() ) = 'FILE' then
* The image is stored as a file from which ORDSource creates a BFILE.
ord_content_type := localImage.getMimeType();
ord_content_length := localImage.getContentLength();
ord_content_bfile := localImage.getBFILE();
elsif upper( localImage.getSourceType() ) = 'HTTP' then
* The image is referenced as an HTTP entity, so we have to redirect
* the client to the URL which ORDSource provides.
http_status := 302;
http_redirect := localImage.getSource();
else
* The image is stored in an application-specific location for
* which no default action is available.
null;
end if;
end;
This works just fine, now i want to transform the procedure so it returns thumbnails of the original image.
i tried to put folowing code right after the select
localImage.process('maxScale=32 32');
localImage.setproperties;
but it never returns thumbnails
(500 internal server error)
how do i have to transform my code to get back thumbnails without changing the original image in the database of course
thx

Hi,
This is failing because BLOBs have to be locked before they can be written. (By default, the Web Agent uses HTTP errors. Change the request from .../mediaget/... to .../~mediaget/... and you'll see the real SQL error.)
However, if you change the SELECT statement to include FOR UPDATE, then you'll end up permanently changing the data in the database, which is not what you want. (The Web Agent does a commit at the end of each successful request.)
The most efficient approach would be to create a thumbnail column in the table, and store the thumb-nail images there. Thumb-nail images could be created either when media is inserted into the database or the first time a thumb-nail is requested by a client. Alternatively, you can always create a thumb-nail at retrieval time, but image processing such as this is a relatively expensive operation - it would certainly slow down the server if you had lots of concurrent users, all retrieving thumb-nail images.
If you still want to create a thumb-nail dynamically (throwing it away once its been delivered to the client), you can use a temporary BLOB. For example, you could do something like the following (WARNING: typed, but not tested!!).
In the declarative section, add:
thumbnail ordsys.ordimage;Leave the SELECT statement alone (don't add FOR UPDATE), and create the thumb-nail image as follows. See "Oracle8i Supplied PL/SQL Packages Reference" for more information on the DBMS_LOB package and the dbms_lob.createTemporary method. See "Oracle8i Application Developer's Guide - Large Objects (LOBs)" for more information on LOBs in general.
thumbnail := ordsys.ordimage.init();
dbms_lob.createTemporary( thumbnail.source.localdata,
true,
dbms_lob.session );
localImage.processCopy( thumbnail, 'maxScale=32 32' );
ord_content_type := thumbnail.getMimeType();
ord_content_length := thumbnail.getContentLength();
ord_content_blob := thumbnail.getContent();The Web Agent automatically frees temporary BLOBs once the data has been delivered to the client.
Hope this helps,
Simon
null

Similar Messages

  • How to obtain date of creation if image is obtained using getImage()

    When Image is obtained using getImage() method , how to
    obtain date of creation or another header value if image is
    obtained using getImage method.

    Actually, some formats do indeed have creation or modification dates built in. e.g. http://www.w3.org/TR/PNG-Chunks.html#C.tIME. (Of course since most programs save a new copy of the file every time, the two dates are the same.) However, just because formats have this data doesn't mean it's reliable or even present. Your best bet is to pass creation dates in an Applet param tag for applets (assuming you were referring to Applet.getImage()) or to parse out a filename from a classloader URL and use a File object to check (assuming you were instead referring to Toolkit.getImage(URL)). That's the best answer I have without knowing more about what you are trying to accomplish.

  • How to tell if an Image is loaded using Toolkit.getImage()

    If I use Toolkit.getImage(url) it always returns an Image object, no matter if the image located at that url is a correct image or not.
    The w/h is always -1, -1 right after loading (since it hasn't been loaded completely of course).
    Anyone know how I can tell if a correct image is loaded or not, without adding a MediaTracker?

    Why don't you want to use a MediaTracker? It is by far the most convenient way to do what you want to do.
    Huw

  • Path in getImage

    Hello
    my applet class is loaded successfully in the directory of "c:\applet\applet.class", and in my applet program, i want to create a image by "getImage". Therefore, i use the following code :
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    image = toolkit.getImage("C:/applet/picture.gif");
    The image can be displayed, However, if the image file is not in the folder of "applet", then the image cannot be created, for example ;
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    image = toolkit.getImage("C:/picture.gif");
    Is there is a security problem in applet that cannot access other folder or path other than the document base of the class or other problems?
    thanks.

    If your image file is in the same folder where is the class file so u dont need to include the complete path otherwise u need to include it.
    secondly when you execute the application on your system(single system) you have to use the path as "c:\applet\image.gif". And when you execute the application on a web server, you have to use the path like "/applet/image.gif". Hope you got it now, and try it.

  • GetImage() throws nullpointerException in Netscape (but not IE)

    1. Does getImage work on Netscape Navigator? When I load pictures to my applet, NN's java console doesn't say anything. After creating a new Panel that actually uses the Images, applet gives a nullPointerException because of the images. The same code works in Internet Explorer and appletviewer.
    2. What ways do I have for loading Images to my applet? Is there an optional way other than getImage?
    Thanks in advance,
    Rakhi
    Here's the code sample :
    The commented areas are the various possiblities I have tried without success.
    import java.awt.*;
    import java.net.*;
    import java.awt.image.*;
    import java.applet.*;
    public class ImageTrial extends Applet {
    Image baseImage;
    public void init() {
    baseImage = getImage(getCodeBase(),"xxx.gif");
    //baseImage = getImage(getDocumentBase(),"xxx.gif");
    /*try {
    URL u = new URL("http://localhost:8080/xxx.gif");
    baseImage = getImage(u);
    } catch (MalformedURLException m) {m.printStackTrace(); }
    /*try {
    URL u = new URL("http://127.00.00.01/xxx.gif");
    baseImage = getImage(u);
    } catch (MalformedURLException m) {m.printStackTrace(); }
    /*try {
    URL u = new URL(getDocumentBase(),"xxx.gif");
    baseImage = getImage(u);
    } catch (MalformedURLException m) {m.printStackTrace(); }
         /*MediaTracker mt = new MediaTracker(this);
    mt.addImage(baseImage,0);
    try {
    mt.waitForID(0);
    catch (InterruptedException e) { e.printStackTrace(); }
    if (baseImage == null)
    System.out.println("image is null");
    else
    System.out.println("image is not null");
    repaint();
    public void paint(Graphics g) {
    if (baseImage == null)
    g.drawString("IMAGE DISPLAY ERROR:IMAGE IS NULL",10,10);
    else
    g.drawImage(baseImage,10,10,this);
    The following is the HTML code:
    <APPLET CODEBASE="/jsdk/webpages/NeGraphical" CODE="ImageTrial.class" WIDTH = 100 , HEIGHT = 100>
    </APPLET>

    Hi !
    I've tried this code and it works on both IE and Netscape:
    import java.awt.*;
    import java.net.*;
    import java.awt.image.*;
    import java.applet.*;
    public class ImageTrial extends Applet
      Image baseImage;
      public void init()
        URL imageURL;
        Class cl = ((Applet)this).getClass();
        imageURL = cl.getResource("java.gif");
        baseImage = getImage(imageURL);
        if(baseImage == null)
          System.out.println("image is null");
        else
        System.out.println("image is not null");
        repaint();
      public void paint(Graphics g)
        if(baseImage == null)
          g.drawString("IMAGE DISPLAY ERROR: IMAGE IS NULL",10,10);
        else
          g.drawImage(baseImage,10,10,this);
    }With this html code:
    <HTML>
      <HEAD>
        <TITLE>Image Test</TITLE>
        <BODY BGCOLOR="FFF3A8" text="00686D">
        <CENTER>
        <HR WIDTH=40% ALIGN=CENTER>
        <B>Image Test</B>
        <HR WIDTH=40% ALIGN=CENTER><BR>
        <SCRIPT LANGUAGE="JavaScript">
        <!--
          var _info = navigator.userAgent;
          var _ns = false;
          var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);
           //-->
        </SCRIPT>
        <SCRIPT LANGUAGE="JavaScript1.1">
        <!--
          if(!_ie)
             var _ns = (navigator.appName.indexOf("Netscape") >= 0
             && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0
             && java.lang.System.getProperty("os.version").indexOf("3.5") < 0)
             || _info.indexOf("Sun") > 0));
         //-->
        </SCRIPT>
        <SCRIPT LANGUAGE="JavaScript">
        <!--
           if(_ie == true)
             document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" ' +
             'WIDTH = 400 ' +
             'HEIGHT = 200 ' +
             'align = baseline ' +
             'codebase = "/plugin/j2re1_3_0_win.exe"><NOEMBED><XMP>');
           else if(_ns == true)
             document.writeln('<EMBED ' +
             'type="application/x-java-applet;version=1.3" ' +
             'width=400 height=200 align=baseline ' +
             'code="ImageTrial.class" ' +
             'pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html" ' +
             'frame="task"><NOEMBED><XMP>');
            //-->
          </SCRIPT>
          <APPLET CODE="ImageTrial.class"
            ALIGN="baseline"
            WIDTH="400"
            HEIGHT="200">
          </XMP>
          <PARAM NAME="java_code" VALUE="ImageTrial.class">
          <PARAM NAME="java_type" VALUE="application/x-java-applet;version=1.3">
          <PARAM NAME="scriptable" VALUE="true">
          ALT = "Your browser understands the <APPLET> tag but isn't running the applet, for some reason."
          <B>No JDK 1.3 support for APPLET!!</B>
          </APPLET></NOEMBED></EMBED>
          </OBJECT>
        </CENTER>                    
      </BODY>
    </HTML>Hope it helps...let me know...

  • Getting error while using getImage(URL, filename) and imageUpdate()

    Hello Everyone,
    I am trying to create an image and upload it in an applet. I have kept the image file in the same directory as of the HTML and java-applet file. I have used the getImage(URL, filename) abstract method to do so. The image is not getting uploaded .... PLEASE HELP .... Please find the code attached below.
    import java.awt.*;
    import java.awt.image.*;
    import java.applet.*;
    /*<applet code="ImageCreation_applet" width=1200 height=400>
    </applet>*/
    public class ImageCreation_applet extends Applet implements ImageObserver
         //     Image image1;
              Image image2;
              String s="";
              String image_name="img2";
              public void init()
                        setBackground(Color.yellow);
         //               Canvas c=new Canvas();
         //               image1=c.createImage(40, 40);
                        image2=this.getImage(this.getDocumentBase());
              public void paint(Graphics g)
                   //     g.drawImage(image1, 50, 50, this);
                        g.drawImage(image2, 0, 0, this);
                        g.drawString(s, 300, 300);
              public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h)
                        if((flags & SOMEBITS) != 0)
                                  repaint(x, y, w, h);
                        else if((flags & ABORT) != 0)
                                  s="ERROR";
                                  repaint();
                        return (flags & (ALLBITS|ABORT)) == 0;
         } I am continuously getting the ERROR String.... PLEASE HELP

    troy.cos wrote:
    i dont have enough time to look closer right now, but im pretty sure that:
    flags & ABORTneeds to be two & not one... so like:
    flags && ABORT
    Nope, that isn't the problem here. & is the correct one to use.
    "&" in this case is a bitwise and, while "&&" would be the boolean shortcut and, which does an entirely different thing.

  • Changing getImage MTU (receive window)

    Hi,
    I have an application (snippet below) that receives image, runs fine, but like a dog when the network latency increases.
    The issue is the MTU size, as when it is increased (windows reg) the speed dramatically increases. I can see solutions to this issue if I want to send the image over my own sockets, writing a server application as well.
    Can I change the MTU/receive window that getImage uses?
    URL MyURL = new URL(imgName);
    pic=getImage(MyURL );
    Tracker.addImage( pic,imgID++);
    Tracker.waitForAll();
    Thanks
    Maddiman

    Can I change the MTU/receive window that
    getImage uses?No, because getImage() doesn't use an MTU/receive window. It just does I/O via the URL. You can't change the MTU or receive window of a URL either. You can do it for a Socket via Socket.setReceiveBufferSize(), or there are Windows registry tweaks to do it globally. If you're on Windows you should definitely do one or the other because the default of 8k is pathetically small.

  • AWTimage error when using getImage() through https

    I am trying to display an image on an applet but I am getting an awtimage type of error. I am using the following code:
    URL newLoc = new URL("https://202.124.142.223/test/data/images/");
    filename = "sample.jpg";
    Image i = applet.getImage(newLoc,filename);
    RenderedOp source = JAI.create("AWTImage",i);
    PlanarImage im = source;
    Width = im.getWidth(); <-- i get error in this line. See error below.
    Height = im.getHeight();
    so on so forth...
    ========================================================
    Error: One factory fails for the operation "AWTImage"
    Occurs in: javax.media.jai.ThreadSafeOperationRegistry
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at javax.media.jai.FactoryCache.invoke(FactoryCache.java:130)
    at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.jav
    a:1682)
    at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeO
    perationRegistry.java:481)
    at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:340)
    at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:830)
    at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:878)
    at javax.media.jai.RenderedOp.getWidth(RenderedOp.java:2190)
    at IPanel.getImage2(IPanel.java:454)
    at IPanel.loadImage(IPanel.java:282)
    at c21Appletv3Integrated.loadImage(c21Appletv3Integrated.java:1637)
    at listener.run(listener.java:158)
    at java.lang.Thread.run(Thread.java:534)
    Caused by: java.lang.RuntimeException: MediaTracker is unable to load the AWT im
    age.
    at com.sun.media.jai.opimage.AWTImageOpImage.layoutHelper(AWTImageOpImag
    e.java:93)
    at com.sun.media.jai.opimage.AWTImageOpImage.<init>(AWTImageOpImage.java
    :151)
    at com.sun.media.jai.opimage.AWTImageRIF.create(AWTImageRIF.java:65)
    ... 16 more
    ==========================================================
    I tried this code before but it works pretty well. However, when I'm using https instead of plain http, I happen to encounter this type of error.
    Can somebody help me solve this problem?
    Thanks in advance for your help.

    Timothy,
    The 656x devices have a limit on the available data delay values based
    on frequency.  Between 25MHz and 50MHz there are "holes" in the
    available delay range.  Above 50MHz, the full 0 to 1 data delay is
    valid.  If you look in the specifications installed with NI HSDIO
    for the NI 656x, on page 7, Figure 1, there is an illustration showing
    how to compute what the valid range is for the frequency of interest.
    For example, at 40MHz, valid values are:
    0 to 0.2
    0.3 to 0.7
    0.8 to 1
    In the error message posted below, you tried to input a value of 0.71875 which is not within these ranges.

  • ABOUT getImage

    how to use this function? where to find some example?

    here is my source code
    public class SpritDemo extends java.applet.Applet implements Runnable {
    final int quantum = 10;
    Image offScreenImage = null;
    Graphics offScreenGraphics = null;
    Dimension offScreenSize = null;
    /** Initialization method that will be called after the applet is loaded
    * into the browser.
    public void init() {
    Image img = null;
    showStatus("loading iamges...");
    String baseURL = getCodeBase().toString();
    img = getImage(getCodeBase(),"dan.gif");
    while(img.getHeight(this) == -1){
    width = img.getWidth(this);
    height = img.getHeight(this);
    but it stops in the while
    why does this happen?

  • How to use Toolkit.getDefaultToolkit().getImage in JPanel in Java Swing

    Hi Sir,
    I want to know how to use Toolkit.getDefaultToolkit.getImage()
    in JPanel (ie) the class that extends the JPanel.There is no problem to include the Toolkit.getDefaultToolkit.getImage()in JFrame.It is displaying it without any problem.But in JPanel it is showing a problem of cannot resolve symbol.Here i can't use JFrame instead of
    JPanel.So how to solve the problem.Pls.do send the code of how to do this.It is Urgent.
    Thanx,
    M.Ananthu

    you use Toolkit.getDefaultToolkit.getImage() in a JPanel exactly the same way you do in a JFrame.
    You are getting a compile message "cannot resolve symbol". You have made a programming error and since you have not included code there is no way to guess what you did wrong.

  • GetImage() in JApplet

    Hi folks!
    Can anybody help me here - I'm trying to use the getImage() method of JApplet to load images into my Applet (the images required are dependent on info received from a JDBC / Network connection so I want to be selective about the images I load). I know the getImage() method only works during the execution of the Applet's init(). However I have looked on the JApplet FAQ in the tutorial and it states it can be called after init() has finished. Is this possible and, if so, how 'cos I can't get it to work?!? I will need to call getImage() from a method totally independent from init()...
    Any help would be appreciated...

    Hi,
    you can try the blow code. in any AWT or Swing component. But the image url must from the same server that applet's.
    java.awt.Toolkit.getDefaultToolkit().getImage(new URL("the image url"));

  • Problem with getImage/URL

    I hosted a picture on tinypic.com and now, I need to make it an URL so I can use the getImage method in Applet.
    When I try to do this:
    URL url = new URL("http://tinypic.com/blablabla.gif");
    I get this error when I run the applet:
    exception : java.security.AccessControlException : access denied (java.net.SocketPermission tinypic.com resolve).
    How do I solve this?

    i mean:
    a.jar
    inside it
    a.class
    b.gpeg
    and inside a.class:
    this.getImage("/b.jpeg");
    but i misunderstood.
    why you used URL i= new URL("img");
    i think if you are to get image do like this:
    Image img= this.getImage("img.jpeg");
    am i right?

  • How to use getImage() and drawImage() ?

    Hi,
    I hope to use an image in a file "a.gif" and draw the image on a specific point (3,5) of a graph (Graphics graph). Can I use getImage() and drawImage() to do that? Or what other way can I use to do that?
    Thanks.

    Hello,
    you're right. For example:public class ImageView extends JPanel
         private static Image[] images = new Image[10];
         private Toolkit kit = Toolkit.getDefaultToolkit();
         public ImageView
              for(int i=0; i<images.length; i++){
                   images[i] = kit.getImage(imagePath+(i+1)+".gif");
         public void paintComponent(Graphics g)
              super.paintComponent(g);
              g.drawImage(images[1], 3, 5, Color.WHITE, this);
    }But theres no guarantee that your images are loaded, have a look
    at [url http://java.sun.com/docs/books/tutorial/uiswing/painting/improvingImageAnim.html]media-tracker  for this purpose.
    regards,
    Tim

  • Always return "Image Object" in Toolkit.getDefaultToolkit().getImage();

    A : Image source = Toolkit.getDefaultToolkit().getImage("C:/aa.jpg");
    B : Image source = Toolkit.getDefaultToolkit().getImage("");
    generally, B may be null. but it is not null.
    so I look at "javax.swing.ImageIcon" class :
    <Part of ImageIcon source>
    public ImageIcon(String filename, String description) {
         image = Toolkit.getDefaultToolkit().getImage(filename);
    if (image == null) { //This code is invaild.
    return; //never return.
         this.filename = filename;
    this.description = description;
         loadImage(image);
    Do you thinking it?
    Bug?

    getimage may not return null in the current implementation but they wanted maybe get sure that no nullpointerexception occures.
    it's not a bug - it's a feature :-)

  • ImageIcon.getImage() returning null

    Hi,
    I have a class, say ABC, which extends ImageIcon....when I do .getImage() ...its returning null...any idea why? I know the ABC icon exists, b/c i can add it to a JLabel and see it...but when I do getImage its null...
    thanks

    Take a look at what I did in the last few lines...
    import java.awt.*;
    import java.net.*;
    import javax.swing.*;
    public class CompoundIcon implements Icon {
        private Icon left, right;
        private int gap;
        public CompoundIcon(Icon left, Icon right, int gap) {
            if (left == null || right == null)
                throw new NullPointerException();
            this.left = left;
            this.right = right;
            this.gap = gap;
        public int getIconHeight() {
            return Math.max(left.getIconHeight(), right.getIconHeight());
        public int getIconWidth() {
            return left.getIconWidth()+ gap + right.getIconWidth();
        public Icon getLeft() {
            return left;
        public Icon getRight() {
            return right;
        public void paintIcon(Component c, Graphics g, int x, int y) {
            int h = getIconHeight();
            left.paintIcon(c, g, x, y+ (h-left.getIconHeight())/2);
            right.paintIcon(c, g, x+left.getIconWidth()+gap, y+ (h-right.getIconHeight())/2);
        public static void main(String[] args) throws MalformedURLException {
            JPanel p = new JPanel(new GridLayout(0,1));
            URL url1 = new URL("http://forum.java.sun.com/images/toolbox_settings.gif");
            URL url2 = new URL("http://forum.java.sun.com/images/toolbox_watches.gif");
            URL url3 = new URL("http://forum.java.sun.com/images/toolbox_dukedollars.gif");
            Icon radioIcon = UIManager.getIcon("RadioButton.icon");
            ButtonGroup bg = new ButtonGroup();
            add(url1, p, bg, radioIcon);
            add(url2, p, bg, radioIcon);
            add(url3, p, bg, radioIcon);
            JFrame f = new JFrame("Example");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(p);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
        static void add(URL url, JPanel p, ButtonGroup bg, Icon radioIcon) {
            CompoundIcon icon = new CompoundIcon(radioIcon, new ImageIcon(url), 3);
            ImageIcon right = (ImageIcon) icon.getRight();
            System.out.println("right width = " + right.getImage().getWidth(null));
            JRadioButton btn = new JRadioButton(icon);
            p.add(btn);
            bg.add(btn);
    }

Maybe you are looking for