Saving Images from URL

Hi
i am trying to save an image from the internet i am able to view them in my program but when i try to save i get the Error
javax.imageio.IIOException: Can't read input file!
If anyone could point out were i am going wrong or give a few suggestions on what to do this would be very helpful.
Below is the code i am using to to get the image from the internet and try to save it
public Image loadURL()
     Image image = null;
     try
          URL url = new URL(UrlLocation);     
          image = ImageIO.read(url);               
          File2 = url.toString();               
     catch (IOException e)
          e.printStackTrace();
     return image;     
public void saveImage(String ImageType)
          try
               FileDialog openfiledialog = new FileDialog(new Frame(),
               "Please choose Image to save",FileDialog.SAVE);
               openfiledialog.setVisible(true);          
               if (openfiledialog.getFile() != null)
                    File file = new File(openfiledialog.getDirectory(),
                    openfiledialog.getFile() + "." + ImageType);                                   
                        File outputfile = file;               
                    ImageIO.write(out, ImageType, outputfile);
          catch (IOException e)
               e.printStackTrace();
     }

Umm, you need to actually read the image bytes from the external webserver. It will do you good to read the javadoc for URLConnection (retrieved through URL). You can read an InputStream from it, and then you can for example put what you read into an ByteArrayOutputStream. You can ask this output stream for a byte array containing what has been written to it, and then you can write this byte array into a FileOutputStream. There may be ways to make this more effective, but these steps are essentially what should happen to solve your problem.

Similar Messages

  • Saving images from camera raw in new CC suite

    Hi Im having trouble re saving images from new adobe cc bridge camera raw, images once saved then show in bridge with no adjustments done in camera raw and the images are downsized to KB size images even from a 9.20mb raw image, Ive looked at setting or rather preferences and totally lost please help!!
    Thank you
    Jon

    This forum is actually about the Cloud, not about using individual programs
    Once your program downloads and installs with no errors, you need the program forum
    If you start at the Forums Index http://forums.adobe.com/index.jspa
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says ALL FORUMS) to open the drop down list and scroll
    http://forums.adobe.com/community/bridge

  • Saving images from internet

    how do i save images from the internet to my iphone photo library?

    Page 79 of the manual:
    "Saving Images from an Email Message or Webpage
    You can add images attached to an email message or webpage to your Photo Library.
    Add a photo to your Photo Library: Press and hold the photo, then tap Save Image.
    The image is added to the Camera Roll album. You can upload your Camera Roll
    pictures to your computer’s photo application by connecting iPhone to your computer. "
    http://manuals.info.apple.com/enUS/iPhone_UserGuide.pdf

  • How can I keep people from saving images from my website?

    How can I keep people from saving images from my website?

    Hi,
    have a look at this thread
    http://discussions.apple.com/thread.jspa?messageID=5645821&tstart=0#5645821
    and the link I posted in that thread
    However there's no way to avoid that people grab photos from your website. Nevertheless there are ways for making it a little more difficult.
    Regards,
    Cédric

  • Download Images from URL

    I want to save images to memory 50 images
    My software processing ----
    1. Download Image from URL every 60 secs and all downloaded images have time to use 15 mins
    2. When download image done save images to memory
    3. Then show images in picturebox
    4. When user click button get next image form memory and delete old image from memory
    5. If what images not use in 15 mins auto delete from memory
    Help me ... Thank you a lot 

    Ok chechk the below method/Events that will download 50 image and fill a List<image> object into memory, you need to add a picturebox1 and button1 to your form, I used my profile pic here on msdn the link you've send didn't work:
    //Global Variables
    List<Image> li = new List<Image>();
    int second = 0; //Form Initaile
    public Captcha()
    InitializeComponent();
    //Async download event
    private void ReadCallback(IAsyncResult asynchronousResult)
    HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
    HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
    using (StreamReader streamReader1 = new StreamReader(response.GetResponseStream()))
    li.Add(Image.FromStream(streamReader1.BaseStream));
    pictureBox1.Image = li[0];
    //Download Method for 50 images
    private void DownLoadImages()
    try
    for (int i = 0; i <= 50; i++)
    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri("https://i1.social.s-msft.com/profile/u/avatar.jpg?displayname=fouad%20roumieh&size=extralarge&version=00000000-0000-0000-0000-000000000000"));
    request.BeginGetResponse(new AsyncCallback(ReadCallback), request);
    catch (WebException ex)
    //Form Load
    private void Captcha_Load(object sender, EventArgs e)
    DownLoadImages();
    And here on button click event we remove element and show the next one into picture box, and if used up all image we call the async download messages again to get a new list of images:
    private void button1_Click(object sender, EventArgs e)
    li.RemoveAt(0);
    if (li.Count > 0)
    { //Show next
    pictureBox1.Image = li[0];
    else
    DownLoadImages();
    Also here a timer event I didn't enable but you can enable to check for the 15 mins and destroy the images list if passed:
    private void timer1_Tick(object sender, EventArgs e)
    second = second + 1;
    int minutes = second / 60;
    if (minutes >= 15)
    li.Clear();
    //Call downloadimages or else...
    Fouad Roumieh

  • Saving images from web on itouch?

    My itouch stopped saving images from Safari?

    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Go to Settings>Safari and Clear History, Cookies and Data
    - Try a different browser like Chrome

  • I saved images from an imessage.  now when I open Imessage, the pictures will not go away. When I press "done" the pictures remain. Cannot send a message

    I saved images from an imessage.  Now when I open Imessage, the pictures are displayed on the screen.  When I click on "done" the images do not go away.
    Therefore, I cannot send a message.

    Quit the app completely and try again. Go to the home screen first by tapping the home button. Double tap the home button and the task bar will appear with all of your recent/open apps displayed at the bottom. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner of the app that you want to close. Tap the home button or anywhere above the task bar.
    Or try this.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.

  • Issues saving images from the internet!!!

    I just got my iPhone 4s and I am having issues saving photos from Tumblr onto my phone. The tap and hold does not work, it doesn't come up with the menu at the bottom to save the photo, it just gives me the option to copy the photo which doesn't help me one tiny bit. Am I being stupid or something? It seems so simple...

    is this wap or wifi internet? if its wap like over gprs go to tools in the browser options when on the page and go to view images you can save them from ther. if its wifi then you cant

  • Loading saved images from code

         I'm creating a single-page application with CQ and AngularJS, and the nature of my app is requiring that I pull my images from code rather than into a paragraph system via the UI. Does anyone know how to accomplish this? Does CQ have some built-in methods for pulling that resource from an image name or something?

    Your reply has a lot of good info in it, thanks. I'm not using a clientlib anywhere, though it sounds like I should be. Let me describe a little better where I'm at, and maybe you can make some suggestions. I've been using CQ for about two months now.
    I have a roughly 8-page application that I'm working on. Adobe CQ is being used only for the UI side. All persistence and business logic is being done on a completely separate server that I'm connecting to via RESTful services using a single, master JSON string which contains all the information I need at all steps of the process. The navigation is essentially a wizard-style sequence where each step results in a round trip of the JSON to and from the server. I have four separate brandings that I'll have to do, based on that which is associated with a particular user.
    My solution so far is a single-page application based on AngularJS. This means I have a "main" page in CQ which uses "maintemplate" attached to a "maintemplate.jsp" component that includes a parsys where I drop an "angularview" component.
    This page renders out the header and footer of my app to the browser, with an empty div where the Angular view will be placed. Each of the pages in my app I have created in pages underneath "main", pointing to another template called "partialtemplate", which does nothing to the component each page calls (no header, footer, etc.).
    Each of these partial page components contain a mix of text, images, and form elements. The images in these partial pages are what I'm concerned about. There's no way to edit these in the authoring view, since I'm not using CQ's full-page-refresh navigation model. So, I have to hard code all the images, text and other content into each partial component.
    I have all my components in /apps/project/components, and the partials underneath that in /components/partials. Javascript files I have in /components/js (this is probably where I need to use a clientlib) and I'm using relative URLs from the maintemplate component to pull them. I'm also using /etc/designs/project as a location for all my css.
    My idea for the branding will be to programmatically adjust the current design path depending on user data (I haven't verified this will work) and create a new design path for each, with sling:superResourceType pointing to the master design so I don't have to have multiple copies of global css files.
    The images in question are inside each of the partials. Since they might change based on marketing goals, I need these to remain exposed to the page authors, so putting them in the DAM is the only choice I see; indeed, isn't that what the DAM is for?
    I'm still fumbling through CQ, trying to find out the best way to do things. If you can make any recommendations, I'd be grateful. Time is precious, so I don't have a lot of time to rewrite the architecture, but if you see some way I can make a small change and save myself some work later, I'm all ears.

  • Saving images from facebook...low-res? Please help

    Hi. I'm working on our school's yearbook through walsworthyearbooks' online design. I saved an image from facebook that we need, but it turns out incredibly small and pixelated. Walsworth staff can't help me.
    I put the image in photoshop, and it looks to be a normal size, and is not pixelated. the image I'm trying to put in right now is 400X474 pixels and I changed the resolution from 72 to 150 on photoshop.  I've tried PNG and JPEG.
    What can I do? I even tried taking a screenshot of the image on facebook so that it wouldn't be saved directly from facebook. The image fits the entire screen, so I don't know why it would turn out so small and messy when put into an online designer.

    Put a link to the facebook image here. If the image on facebook is 400px by 474pixels the image should print quite well as a portrait sized around  2" x 2.37"  for 200 DPI should be good for a yearbook image.

  • Saving images from Muse gallery.

    Hi,
    My client has recently addressed an inquiry to me. He was trying to download images from any gallery-page on the website that i designed from him: http://www.andreyisakov.com
    It is a simple gallery created with a lightbox slideshow widget.
    However, it is only possible to save the entire webpage, i.e. the gallery as a whole. There seems to be no way to save a single image (tried in Safari and Chrome both on Win and Mac).
    Does anybody know the solution to the problem or a workaround making it possible to save images from Muse gallery?
    Many thanks in advance!

    Hi
    Users can save the image displayed on page with a right click action > save image.
    Are you looking for some specific function for saving image files on page ?
    Thanks,
    Sanjit

  • Reading images from URL without knowing the format

    I have an image url like this: http://example.com/image.php?id=5605. How do I get the actual image from such an URL? I have tried using ImageIO.read and loading the url directly into an ImageIcon without success.

    yeah,
    I knew a little about linearization and but the idea was to help quick loading the very first page of a document while the rest of the data still is arriving. Not exactly what I needed here.
    Anyway, you have just confirmed my fears, I will have to know the document size, where exactly it ends on my stream, in order to correctly load it.
    I appreciate your help sir. Thanks for your time.
    Best regards.

  • Displaying images from url's (9i)

    Is it possible to some how display images retrieved from a url within an image item? I know its possible to display images from within the database and from a file but these images are stored on another server and all i have is a web address, can it be done? Also is it possible to dislpay a series of images that are retrieved in this way in a report?
    Any help is much appreciated.

    Hi,
    this would require a Java Bean to be written. Its not natively possible in Forms
    Frank

  • Downloading images from URL

    Hi All,
    I am trying to write code to download images from given URL. My application will take URLs by querying sql server, will pass that URL to my method and download images to a specific folder. There will be almost 400 images a day to download. I figured out some options like getImage(). But I would like to get idea from you to find the most efficient way to do this.
    Here is the initial code I have come up with
    private void downloadimage() throws Exception {
              String sql = "SET NOCOUNT ON SELECT DISTINCT activation_group_id FROM ACTIVATION_GROUP";
              JdoServer jdo = JdoServer.getInstance(dbKey);
              RowSet rs = jdo.getRowSet(sql);
              while (rs.next())
                   //will fetch URL from rs here, currently passing hardcoded URL for testing purpose.
                   // Get the image
                   MediaTracker tracker;
                   tracker = new MediaTracker(this);
                   Toolkit toolkit = Toolkit.getDefaultToolkit();
                   Image image = toolkit.getImage(new URL ("http://digitalcontent.cnetchannel.com/70/e1/70e18a07-7356-4a54-8498-1493da1dec3d.jpg"));
                   tracker.addImage(image, 0);
    Somehow, tracker = new MediaTracker(this) is giving me the consstructor mediatracker(myclassname) not defined error.
    I am a recent graduate and it's my first project... any help would be appreciated :)
    Thanks

    Ok, here is the update... I have tried something new which is here...
    import java.io.*;
    import java.net.*;
    public class image
         public static void imageDL(String imageURL, File Outputfolder)                     
                   throws MalformedURLException,IOException,FileNotFoundException
              OutputStream out = null;
              URLConnection conn = null;
              InputStream  in = null;     
              int imgNameIndex = imageURL.lastIndexOf('/');
              if (imgNameIndex >= 0 && imgNameIndex < imageURL.length() - 1)
                   try {
                        URL url = new URL(imageURL);
                        String file = url.getFile();
                        file = file.substring(7);
                        out = new BufferedOutputStream(new FileOutputStream(Outputfolder.getAbsolutePath()+ file));
                        conn = url.openConnection();
                        in = conn.getInputStream(); // here's where I am getting error
                        byte[] buffer = new byte[1024];
                        int numRead;
                        long numWritten = 0;
                        while ((numRead = in.read(buffer)) != -1)
                             out.write(buffer, 0, numRead);
                             numWritten += numRead;
                        System.out.println(imageURL.substring(imgNameIndex + 1) + "\t" + numWritten);
                   catch (Exception exception)
                        exception.printStackTrace();
              else
                   System.err.println("Could not figure out local file name for " + imageURL);
         in.close();
         out.close();
    }Everythign works fine, until it reaches in = conn.getinputstream();
    It throws error there:
    java.net.ConnectException: Connection timed out: connect
         at java.net.PlainSocketImpl.socketConnect(Native Method)
         at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
         at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
         at java.net.Socket.connect(Socket.java:452)
         at java.net.Socket.connect(Socket.java:402)
         at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
         at sun.net.www.http.HttpClient.openServer(HttpClient.java:402)
         at sun.net.www.http.HttpClient.openServer(HttpClient.java:618)
         at sun.net.www.http.HttpClient.<init>(HttpClient.java:306)
         at sun.net.www.http.HttpClient.<init>(HttpClient.java:267)
         at sun.net.www.http.HttpClient.New(HttpClient.java:339)
         at sun.net.www.http.HttpClient.New(HttpClient.java:320)
         at sun.net.www.http.HttpClient.New(HttpClient.java:315)
         at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:512)
         at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:489)
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:617)
    Any insight??

  • Saving images from LR Mobile with edits.

    I'm having a bit of trouble saving images on my ipad with the current edits.
    To me it seems I have to manually sync the edited image first, otherwise Lr just saves a JPG of the original image to my photostream rather than a copy with adjustments on it.
    Am I missing something or is this the way it works?
    Thanks for any insight.

    Correct. As long your image is in Develop mode (same with presets and crop) and you would like to share from there you need to maually force sync your changes first. This is already logged as in internal bug. Thanks, Guido

Maybe you are looking for

  • Does Lion Recovery tool to reinstall OS X delete all your files?

    I don't know why Apple can't make this clear:  Does the reinstalling option in Recovery simply reinstall OS X over the old OS, or does it wipe the hard drive clean, including your media, documents iLife updates, etc?  Because my login freezes with th

  • Please support CameraRoll properly on Android

    With some dismay I just tested AIR 16 beta to find that the CamerRoll problems have not been addressed in any way. It still can't load Picassa images on older versions of Android and is comprehensively broken on Android 5. As it is I'm about to relea

  • Physical and logical partation of cube

    hi can i get scenerio for logical and physical partation of cube. based on year or calmonth that is called physical partation? or not what is logical partation

  • Inserting text into table cells in Powerpoint

    Hi I have a named table ClientInfo on Slide 3 in Powerpoint. How can I programmatically insert text into the table's cells? Thanks Regards

  • How to create/get an OrdDicom instance

    Hey, guys, does anyone try to use the OrdDicom.jar to do some development? Now I have a rookie question: how to create/get an OrdDicom instance? It seems the OrdDicom class's construtor is private and no related factory method, so is there some other