Saving an Image from a url
I need to write a simple(even dos based) app that saves an image from a url (ie http://www.google.com/images/logo.gif) into c:\temp\*filename*
thanks alot for the help
Its just like reading/writing a regular file. Check out the 'Custom Networking" tutorial found on this page:
http://java.sun.com/docs/books/tutorial/
Similar Messages
-
[noob needs help] Loading image from a URL
Hey everyone. I'm new here. And I'm new at J2ME as well.
I have a simple school project and I have doubts about it. I've searched everywhere on the net yet I could not find the solution. Anyways, I do understand the concept of loading images by putting the files in the "res" folder and use:
try
img = Image.createImage("/burgerimgsmall.jpg");
catch (Exception e)
e.printStackTrace();
But my project requires me to load an image from a URL. How do I go about doing that? If it helps, here's the URL:
http://img.photobucket.com/albums/v703/punkgila/burgerimgsmall.jpg
Thanks guys!Don't worry, downloading image from http is also simple. Look into Photoalbum demo in wtk2.5
-
I want to download an image from the url and image is in byte format
hi
i want to download an image from the url
http://www.tidelinesonline.com/mobile/j2me_v1?reqType=imageJoin&imageCount=1&month=1&day=1&year=2008&id=1&imageWidth=230&imageHeight=216&imageDepth=8&imageUnits=feet&imageType=JPG&msisdn=456
first 5 digits will be the length of the image,we need to download except first 5 digits and display an image file
i need to finish this today
pla reply if any body knows solution for this.
thanks in advance
MrajYou do not need to do anything - iPhoto always keeps the original and you can revert to it at any time
If you want to be able to see the original and the cropped version in iPhoto at the same time duplicate the photo (this does not really duplicate but simply starts a new edit stream for the photo - command-d) and crop the duplicate
LN -
Inserting an image from an URL in a BLOB
Hello all,
As it's said in the title, I need a PL/SQL procedure to insert a image from web URL in a BLOB table column.
How can I do that?
Thanks in advance for your help.
Maxfound this on the internet http://www.oracle-base.com/articles/misc/RetrievingHTMLandBinariesIntoTablesOverHTTP.php
CREATE TABLE http_blob_test (
id NUMBER(10),
url VARCHAR2(255),
data BLOB,
CONSTRAINT http_blob_test_pk PRIMARY KEY (id)
CREATE SEQUENCE http_blob_test_seq;
CREATE OR REPLACE PROCEDURE load_binary_from_url (p_url IN VARCHAR2) AS
l_http_request UTL_HTTP.req;
l_http_response UTL_HTTP.resp;
l_blob BLOB;
l_raw RAW(32767);
BEGIN
-- Initialize the BLOB.
DBMS_LOB.createtemporary(l_blob, FALSE);
-- Make a HTTP request and get the response.
l_http_request := UTL_HTTP.begin_request(p_url);
l_http_response := UTL_HTTP.get_response(l_http_request);
-- Copy the response into the BLOB.
BEGIN
LOOP
UTL_HTTP.read_raw(l_http_response, l_raw, 32767);
DBMS_LOB.writeappend (l_blob, UTL_RAW.length(l_raw), l_raw);
END LOOP;
EXCEPTION
WHEN UTL_HTTP.end_of_body THEN
UTL_HTTP.end_response(l_http_response);
END;
-- Insert the data into the table.
INSERT INTO http_blob_test (id, url, data)
VALUES (http_blob_test_seq.NEXTVAL, p_url, l_blob);
-- Relase the resources associated with the temporary LOB.
DBMS_LOB.freetemporary(l_blob);
EXCEPTION
WHEN OTHERS THEN
UTL_HTTP.end_response(l_http_response);
DBMS_LOB.freetemporary(l_blob);
RAISE;
END load_binary_from_url;
EXEC load_binary_from_url('http://forums.oracle.com/forums/themes/english/resources/oralogo_small.gif'); -
Multiple images from static URL
I am currently writing an applet that grabs radar images from a static URL. The image on the URL is updated every 15 minutes. I have a timer that will grab the image every 15 minutes and put it in an image[] array. Eventually I will be looping these images, and let the user define how far back to loop and how fast the loop is. Right now, though, every image it grabs is the same as the very first one. For testing purposes I have the URL currently set to an online panda cam with a timestamp (so I dont have to wait 30 minutes every build to see if it works on the radar URL). If I start the program at 12:47:51(timestamp on webcam) , it grabs a new image every 10 seconds. After a few minutes I have an array of images with the timestamp 12:47:51, every image is identical.
well, I have the url
"url"
and the image[] array
"imageArray[x]"
in the actionPerformed for the timer:
imageArray[x] = getImage(url); Currently I just have a button to step thru the images.
backg.drawImage(imageArray[counter],0,0,radarWidth,radarHeight,Color.white,this);Just to see if that worked I loaded the array with images from different URLs, and I was able to display them all without problem. Just when I use the static URL do I get the problem of the repeated image. -
Hi,
I've looked through the Java Swing tutorial and I've searched the forums here, but I haven't figured out how to load an image from a URL into my GUI and display it.
I don't want the image to be at certain coordinates, as I am using the FlowLayout. My problem is: how do I load an image from a URL, then display it in a JPanel, such as a JScrollPane?
I'm sorry if I missed any tutorials or similar things about this topic, but if anyone could provide some advice, I would appreciate it.
Thanks,
Dantry this:
try {
JLabel label = new JLabel(new ImageIcon(new URL("http://developers.sun.com/forums/img/gold.gif")));
JScrollPane sp = new JScrollPane(label);
catch (MalformedURLException x) {
x.printStackTrace();
} -
I need to download image from the url and the image is in byte format.
hi
i need to download image from the url
http://www.tidelinesonline.com/mobile/j2me_v1?reqType=imageJoin&imageCount=1&month=1&day=1&year=2008&id=1&imageWidth=230&imageHeight=216&imageDepth=8&imageUnits=feet&imageType=JPG&msisdn=456
first 5 digits will be its length,we need to download except 5 digits.
can any one know how to do that.
thanks in advance
Mrajhi
i need to download image from the url
http://www.tidelinesonline.com/mobile/j2me_v1?reqType=imageJoin&imageCount=1&month=1&day=1&year=2008&id=1&imageWidth=230&imageHeight=216&imageDepth=8&imageUnits=feet&imageType=JPG&msisdn=456
first 5 digits will be its length,we need to download except 5 digits.
can any one know how to do that.
thanks in advance
Mraj -
I want to download and image from the url and image is in byte format
hi
i want to download the image from the url:
http://www.tidelinesonline.com/mobile/j2me_v1?reqType=imageJoin&imageCount=1&month=1&day=1&year=2008&id=1&imageWidth=230&imageHeight=216&imageDepth=8&imageUnits=feet&imageType=JPG&msisdn=456
can any one help me to do this i need to finish this today plz help me.
first 5 character 09593 is the length of the image we need to substract image length from total length.
thanks in advance
M.Raj
Edited by: Mraj.Bangalore on May 15, 2008 12:01 AM
Edited by: Mraj.Bangalore on May 15, 2008 12:01 AMhi
thanks for the reply,
that works only if .png file is there in the path.
i worked it out, it is working fine now
try
httpConn = (HttpConnection)Connector.open(url);
is=httpConn.openInputStream();
responseCode = httpConn.getResponseCode();
if(httpConn.getResponseCode() == 200)
ByteArrayOutputStream bStrm = null;
byte[] data = new byte[512];
int contentLen = httpConn.getHeaderFieldInt("Content-Length", 0);
if(contentLen > 0)
response = new byte[contentLen];
else
bStrm = new ByteArrayOutputStream();
int count = 0, tmp =0;
while ((count = is.read(data)) >= 0)
if( contentLen > 0 )
for(int i=0;i<count && tmp+i < contentLen;i++)
response[tmp+i] = data;
tmp += count;
else
bStrm.write(data, 0, count);
// if( aborted)
// break;
data = null;
System.gc();
if( contentLen <= 0 )
response = bStrm.toByteArray();
bStrm.close();
bStrm = null;
System.gc();
else
// main.showAlert("ERROR","Connection failed.Please access again later");
// main.changeToMain();
catch(Exception e){
response = null;
responseCode = 0;
// main.showAlert("ERROR","Connection failed.Please access again later");
// main.changeToMain();
catch(OutOfMemoryError e){
// main.showAlert("ERROR","Not enough memory, please disable some apps or delete files and try again.");
// main.changeToMain();
finally
System.out.println("Before Creation"+response.length);
img = Image.createImage(response, 5, response.length-5);
System.out.println("After Creation");
CanvasImageFile canvas = new CanvasImageFile(this);
midlet.display.setCurrent(canvas);
try
if( is != null )
is.close();
is=null;
catch(Exception ex){
// main.showAlert("ERROR","Connection failed.Please access again later");}
if( httpConn != null )
try {
httpConn.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
httpConn=null; -
How can I use wget, cron and Automator to periodically pull an image from a URL (which is dynamically updated - like a weather map, say - to local storage, and then update a Keynote slide with that image, automatically?
Any particular reason for those specific technologies? wget does not exist on a mac, although you can nstall it I guess. OS X has curl installed which should do pretty much anything you want to do with wget. cron is being replaced by launchd, although cron still exists on mountain lion.
As far as I can tell from automator all the standard 'actions' to access keynote available to it require keynote to be open and running, but does not provide a function to actually open it. So I think you will have to write some applescript, as a minimum to open and quit keynote. I notice that the keynote actions are mostly circa 2005 an wonder if they would even work.
Under utilities in automator 'actions' there is a capability to add applescripts as part of the workflow.
Also, note that cron is being dprecated by Apple and replaced by launchd. that said cron is stil on my mountain lion instalation.
This entry at stackoverflow shows use of cron with curl to get web urls. http://stackoverflow.com/questions/1683620/getting-started-with-cronjobs-on-a-ma c
If I have any time I may try and get this to work as it is quite interesting and new to me. But otherwise, good luck. -
Images from a URL saved to cache?
Hi all,
I have an applet, which is required to download alot of images (maybe 100?)
from different URL's. My question is, will these images be saved to the user's
cache after viewing the applet for the first time (i.e. will they need to be downloaded
again next time the applet is viewed, or will the applet load almost strait away, the
images being loaded from the cache instead?)
My method for doanloading an image is as follows:
import java.applet.*;
import java.applet.Applet;
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
import java.net.*;
import java.io.*;
import java.util.*;
boxUpperLeft = getImage(getDocumentBase(), APPLET_URL+"/misc/box_upperleft.gif");
waitForImage(boxUpperLeft, this);
If there is a better method, or one that is guarenteed to download images to the cache to save on download time in future (assuming of course the client's browser is set to store images and such to the cache for faster loading in future), please let me know.
Thanks in advance
Jaz
Edited by: jazza_guy on Oct 2, 2007 11:38 PMI guess it's very easy for you to test?
-
Help needed for downloading the image from Inage URL
Hello everyone,
I need some help regarding setting a timeout for dowloading image from image URL
Actually I have a hash table with set of image URL's...
for example:
http://z.about.com/d/politicalhumor/1/0/-/6/clinton_portrait.jpg
which gives a image.
for(Enumeration e = google_image_links.elements() ; e.hasMoreElements() ;) {
//System.out.println("final");
//System.out.println(e.nextElement());
try{
System.out.println("Images download started....");
//System.out.println(e.nextElement());
//imageio is the BufferedImagereader object
imageio = ImageIO.read(new URL((String) e.nextElement()));
image_title = created_imagepath +"\\"+ array_words[i] + counter_image_download + "." + "jpg";
img = ImageIO.write(imageio,"jpg", new File(image_title));
imageio.flush();
}catch(Exception e1){
System.out.print(e1);
if(img){
System.out.println("The image " + image_title + " has been saved to local disk succesfully.");
counter_image_download++;
}//end of for loopi am using the above code to download all the image from the Image URL's that r present in hashtable.
The problem i have been encountered with is...
Some URL's does not return any bytes, The code is not totally broken. In such cases, my code is hanging off at that particular URL and waiting to get some output data from the URL. The execution does not proceed furthur But if the URL is a totally broken link, the code is throwing an exception and I am able to handle it successfully.
But in the case of partially broken links, I am not able to go furthur because the code keeps waiting to get some data.
So for this reason I want to setup a timer and tell the code to wait for 5-10 min, in that time if it does not get any data, proceed furthur to download other links...
Please tell me how can I do this.. or plzzz tell me an alternative...
Please help me ans its a bit urgent plzzzz.
Thank you,
chaitanyaHello everyone,
I need some help regarding setting a timeout for dowloading image from image URL
Actually I have a hash table with set of image URL's...
for example:
http://z.about.com/d/politicalhumor/1/0/-/6/clinton_portrait.jpg
which gives a image.
for(Enumeration e = google_image_links.elements() ; e.hasMoreElements() ;) {
//System.out.println("final");
//System.out.println(e.nextElement());
try{
System.out.println("Images download started....");
//System.out.println(e.nextElement());
//imageio is the BufferedImagereader object
imageio = ImageIO.read(new URL((String) e.nextElement()));
image_title = created_imagepath +"\\"+ array_words[i] + counter_image_download + "." + "jpg";
img = ImageIO.write(imageio,"jpg", new File(image_title));
imageio.flush();
}catch(Exception e1){
System.out.print(e1);
if(img){
System.out.println("The image " + image_title + " has been saved to local disk succesfully.");
counter_image_download++;
}//end of for loopi am using the above code to download all the image from the Image URL's that r present in hashtable.
The problem i have been encountered with is...
Some URL's does not return any bytes, The code is not totally broken. In such cases, my code is hanging off at that particular URL and waiting to get some output data from the URL. The execution does not proceed furthur But if the URL is a totally broken link, the code is throwing an exception and I am able to handle it successfully.
But in the case of partially broken links, I am not able to go furthur because the code keeps waiting to get some data.
So for this reason I want to setup a timer and tell the code to wait for 5-10 min, in that time if it does not get any data, proceed furthur to download other links...
Please tell me how can I do this.. or plzzz tell me an alternative...
Please help me ans its a bit urgent plzzzz.
Thank you,
chaitanya -
Displaying an image from a URL
I have a program which visits a html page and creates a JComboBox with all the images from that page. When the user selects an image from the combo box it displays that image in a JLabel. This works fine with images that exist, when I try it with an image that doesn't exist I want it to realise that and display a message saying that "the image cannot be found". Heres part of my code that handles the selection:
public void actionPerformed(ActionEvent f) {
JComboBox cb = (JComboBox)f.getSource();
String imageName = (String)cb.getSelectedItem();
try {
imageUrl = new URL(imageName);
catch (MalformedURLException ex) {
System.out.println("Image Collection Error: " + ex);
catch (Exception e) {
System.out.println("Some sort of exception: " + e);
picture.setIcon(new ImageIcon(imageUrl));
});When I select a bad link image from the list I was hoping the catch blocks would trap it and I could make adjustments accordingly, this does not happen. No exception is thrown at all.
Any ideas of what I can do??
Bow_wow.Thanks for your help, I have changed it to the following code:
ImageIcon imageToDisplay = new ImageIcon(imageUrl);
ImageIcon badImage = new ImageIcon("logo.jpg"); // An image I know exists
int status = imageToDisplay.getImageLoadStatus();
if (status == MediaTracker.COMPLETE) {
picture.setIcon(imageToDisplay);
else {
picture.setIcon(badImage);
}It works now, thanks again for your help! -
Hello,
I was wondering if it is somehow possible to download all the images from a page located at a given URL? Any pointers?
Thanks,
jaiOne way to get the images on a page is:
1. Get the page HTML. (E.g. using [Apache HTTP Client|http://hc.apache.org/httpclient-3.x/] )
2. Look for <img src=".." ..> tags in the HTML and construct the full URL of images.
3. For each image URL found above, get the image from server -
Saving an image from Image Field
Hello all!
I am working on a form for someone with a certain request.
I am wondering if images from the Image Field can be saved? I tried right clicking on the image but no menu pops up so I am looking for other options. Are there any ways to work around this?
Thanks in advance!Hi radzmar,
Thanks for the reply. If any scripting was involved, would it be pretty lengthy/complex?
Thanks again! Any information helps -
Loading an image from a url.
I was wondering if it were possible to load an image (just a jpg) from a url. The closest I've come is loading an .mpg from a url or loading an jpg locally using the importIcon function. I can't seem to find anything in the javascript api for this.
URLConnection.getInputStream()with reading from URLConnection.getInputStream() i can't manipulate any data. it's not possible to read some bytes and "unread" modified bytes.
Maybe you are looking for
-
I have two separate itune accounts under two different email accounts and would like to combine them under one account. Is this possible and if so, how do I do it?
-
New inserted detail row is not showing through accessor
I have to insert master and detail row. I insert row in master view and then I get detail row using getAttribute on master view. Then I insert row into detail row. Result is one inserted master row and no data display in detail view. How ever in man
-
I can create this array without a problem: private float[][][] floats = new float[170][170][170]; This one causes an error: private float[][][][] floats = new float[170][170][170][1]; Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError:
-
Download Adobe Premiere / Photoshop Elements 11
Hi, I bought last year a pack with Premiere Elements 11 and Photoshop Elements 11. Both were on dvd, but I registered them on the Adobe Website. As I changed my computer and don't have a dvd player now, I'm looking for a way to have them again, witho
-
ORACLE 10g on Windows : Big bugg
Hi, it's not the first time, I read errors about installing 10g on Windows. This version is not stable. You have to skip DBCA and try to create it manually. It's very strange, no problem on UNIX/Linux and a full of errors for Windows. They hurry up t