Download an image with JS?

I´m trying to download an image from an URL with Javascript using socket.
My first problem was separating the header from the body. I do it by reading line by line and if the line starts with "\n" then it seams to be the body.
A problem with this is that it´s very very slow. Reading a 1x1 pixel png takes 5-10 seconds.
The stranger thing is that I can´t write the content to file. I can write a string to a file, but not the body of the image, toString() doesn´t seem to help.
Anyone with experience or advice?
var img_data = "";
var line;
var body_start = false;
var conn = new Socket;
if (conn.open ("www.test.com:80", "BINARY")) {
var request = "GET /phoenix/images/5_topnavlogo.jpg HTTP/1.1\n" +
  "Host: www.test.com\n" +
  "User-Agent: InDesign ExtendScript\n" +
  "Accept: text/xml,text/*,*/*\n" +
  "Accept-Encoding:\n" +
  "Content-Length: 0\r\n" +
  "Content-Type: application/x-www-form-urlencoded\r\n" +
  "Connection: keep-alive\n" +
  "Accept-Language: *\n" +
  "Accept-Charset: utf-8\n" +
  "\n";
conn.write(request);
while(!conn.eof) {
line = conn.readln(255);
if(line.substring(0, 1) == "\n") {
img_data = line.substring(1);
conn.close();
alert(img_data);
var img_file = new File(File(app.activeScript).parent + '/test.txt');
img_file.open('w');
img_file.write(img_data);
img_file.close();
alert("Done");

http://rorohiko.blogspot.com/2008_07_01_archive.html
demonstrates how to do the basics of what you need.
Cheers,
Kris

Similar Messages

  • I can't download any images with Lightroom from any of my cameras, NIkon NEF, or Canon IMG, or Sony

    I can't download any images with Lightroom 4.4 from any of my cameras, NIkon NEF, or Canon IMG, or Sony DSC images...please advise...I used to download all my images with the previous versions...3.0   I have Mac 10.7.5
    mark

    Sounds like a hardware problem to me.
    Card reader or cable gone bad; or as Victoria said, permissions

  • I use an iMac 10.6.8 with iPhoto '09 to download digital images from Canon DSLRs. Until the last two weeks there has been no trouble whatever importing images by  a USB connection from either camera to the Mac. Now the process will not kick in. Any ideas?

    I use an Mac OSX 10.6.8 with iPhoto 09 to download digital images from two Canon DSLRs. Until the last week, there has been no problem whatever in launching the import procedure once the USB connection has been connected and the camera switched on. Now the process will not kick in at all for either camera.  I can't find a solution through iPhoto help or from other sources.
    Any ideas to fix?  (I admit I have not tested the USB cable at this time).

    What does "kick in" mean?
    As a Test:
    Hold down the option (or alt) key and launch iPhoto. From the resulting menu select 'Create Library'
    Import a few pics into this new, blank library. Is the Problem repeated there?
    Post back with the result.

  • Download Image with DBMS_LOB

    I want to download the image file stored in database with the DBMS_LOB package within the forms 6i application. The DBMS_LOB.READ can do this but the buffer limit is 32kB! The image file I want to download is with size over 10MB, so that I need to write a loop to read but how can I save and append the buffer content into a file of the local machine during the loop. Please advise, thanks.
    SK

    I think you have to do it in chunks. and I think you have a function to do it.
    Maybe the database forum is better for this question.

  • Can't Download Images with Right-Click on Mouse

    I can't download images by right-clicking my mouse, like I do on my PC. For example, check out http://en.wikipedia.org/wiki/North_Dakota and look at the images of the flag, state seal and map near the top right corner of the page...
    When I place my cursor over any of these images on either my PC or my MacBook Pro, my cursor changes to a hand, indicating that the images are hyperlinked. If I right-click on an image, I can choose a SAVE AS command on my PC, but nothing happens on my MacBook Pro.
    If I left-click on a linked image, it simply zooms in, rather than taking me to another page. I'm using a small Kensington mouse.
    This could be a Firefox problem. I think I recall downloading some sort of extension that allows you to zoom in on images, and I suspect it's more or less taken over. If so, I'll have to track down the name of the extension and try and zap it.
    But I thought I'd check here first, just to see if other people have this same problem - or if you can suggest alternate strategies for downloading images.
    Thanks.

    Well, I found a novel solution - it's called Safari.
    I'll post on the Firefox forum to figure out why I
    can't download images with it, but it seems to work
    just fine with Apple's native browser. Thanks for all
    the tips.
    I just tried it, but I am using firefox 2.0 beta and I had no problems. Not sure what's going on. Have you tried any other pages or pics besides this one, which I don't think it would matter just wondering.

  • I have taken pictures of items that are linked to a database that I am building.  How can I bypass importing into iPhoto and simply downloading the images as "files" not "photos" so I can access them with my database?  thanx.

    I have taken pictures with both my Sony camera and my iPhone of items that are linked to a database that I am building, as well as my website.  How can I bypass importing the images into iPhoto and simply downloading the images as "files" not "photos" so I can access them with my database?  thanx.

    If your Sony has a removable memory card you can use a card reader to copy the image files from to a folder on your Desktop and then move them anywhere you'd like.
    Since the iPhone doesn't have a removable memory card you can try using Image Capture to see if you can manually upload the files to a folder on the Desktop. 
    If you have to import the photos, which are image files, into iPhoto you can then export them out of iPhoto to the Desktop and go from there to your database.  Just because they are in iPhoto doesn't prevent you from using them elsewhere.
    OT

  • Downloading raw images from Canon Rebel XTi and problem with Border FX

    Aperture no longer downloads raw images from my Canon 400D / Rebel Xti and installed Lexar Professional UDMA card. I am able to download images to my Dell laptop. This is a new phenomenon only occurring since about 10 days ago. I am currently able to download images from my Canon 5D.
    Also, my computer has locked up 4 times today when I have been starting Border FX. I have seen a screen saying that I have to restart my computer by holding down the on button. I have the most recent version of the Border FX software.
    Any suggestions please?

    Join the crowd! I just started to experience exactly the same thing on both of my systems. Apparently the latest raw camera drivers broke something related to Canon Rebel cameras. I'm using the Rebel XT.
    I tried a quick experiment the other day. I shot a bunch of test photos forcing the camera to store them as JPEGs. I was able to download those without a problem. I then forced the camera back to raw mode and shot a few more pictures on the same memory card. The JPEGs that I was able to download previously no longer will download and neither will the raw files.
    I tried reverting to the older camera raw driver on my notebook but for some reason it won't let me do that. I haven't tried reverting on the desktop yet.
    Hopefully this problem is fixed quickly. I've got a ton of pictures from a recent vacation I'd like to off load.
    By the way, this affects the iPhoto, Aperture and Image Capture apps.

  • Bridge CS4 won't output to pdf multiple images with same filename

    Hiya...my googling efforts have thus far failed!
    I've got CS4, and in Bridge, I created a New Smart Collection to find all filenames in a folder containing "." or ".jpg" - which in turn searched through all the subfolders like what you used to be able to do in Photoshop CS3.  Very simple stuff, but all the images are jpg's, but in multiple folders (I don't want to move them out of the folders, as the files came from an external source, and there are heaps of folders, and I don't want to pdf each subfolder seperately as it will take forever).
    The problem is that some of the files have the same filenames (again I'd prefer not to rename, as it happens a lot on this project, and they are all over the place).  So whilst Bridge will show the thumbnail images correctly in the content tabbed screen in my New Smart Collection, but once I've done the Output to PDF thing, for example, instead of showing both different images it has pdf only the first image but repeated it twice.  And this happens multiple times throughout the pdf, the more times the same filename is used, the more times the first image gets repeated.
    I know that it is messy to have multiple similar filenames, but why can't bridge just place the image anyway?  It allocated a space for it on the pdf and does show it in bridge, it just doesn't seem to survive the transfer to pdf well.
    The only other thing that I have done is use the below link (which was posted on another adobe forum thread) to create a custom pdf output template (nothing too fancy, just number of rows / columns, size, font etc).  But I've tried using the standard bridge templates and it does the same thing.
    http://www.proficiografik.com/2009/08/03/save-custom-pdf-output-template-in-adobe-bridge-c s4.html
    Any help would be appreciated...even if to tell me that I am being unreasonable!
    UPDATE 16/11/09
    Just to let you know that I seem to have resolved the bug inadvertently with one of the Adobe updates. The below is the link for the AdobeOutputModule-2.1-mul-AdobeUpdate.zip which was released on 2/19/2009 - which allows for headers & footers to be placed in the Ouput pdf. I finally installed it today, and everything seems to be working fine now (i.e. I can pdf multiple images with the same filenames and the pdf will actually show each different image rather than repeating only 1 of the images).
    Must have been a fix installed in the contact sheet templates that get installed with the update - not sure why the original version was corrupted, but I've left that with the Adobe guys (I submitted a bug report - and they were able to replicate the problem but hadn't fixed it as yet).
    http://www.adobe.com/support/downloads/detail.jsp?ftpID=4228
    Message was edited by: djtun71 (16/11/09)

    When I click import from disc I am asked to choose a disc and then I get this message:
    The following photos will not be imported because they are already present in the catalog. To see these photos in the catalog select 'Show in Library' (the import will be canceled).
    This is followed by a long list of images. If I click 'Show in Library' I can see all the images with the same filename. And then they start to automatically write over those images with images from the disc. However they keep the same metadata and keywords from the previous images. If I click on Import and deselect the "don't reimport suspected duplicates" box, it imports only the images that don't share filenames and none of the images that do.
    Is there a way of setting the "Don't reimport suspected duplicates" box in preferences?

  • I have an Air running Mountain Lion. I also have a digital point-and-shoot camera, but have never downloaded any images from the camera to this Air. If I connect the camera to the Air, what might I expect? Will connecting the camera to the Air by a cable

    I have an 11" Air with lots of remaining capacity running Mountain Lion. I also have a digital point-and-shoot camera. I have never downloaded images from the camera to this Air. However, if I just connect the camera to the Air's USB port, with the camera's available cable, and the Air is open, will a program like ImageCapture or iPhoto, auomatically come up, and I can begin to download wanted images? Or, will this sort of connection delete or fry everything on the Air? Do I need any other software on board? Will current Apple onboard programs allow me to download images from my camera and not destroy everything else?

    Answered. Thanks.

  • How to make a podcast with one still image with iMovie 09

    I'm using trying to transfer my podcasts to Vimeo. I've been using iWeb to create a person web site with video and podcasts. I have embedded Vimeo with "html snippet widge." I want to do the same thing with audio, however Vimeo only accept "video" files.
    In my attempt to work around Vimeo's video issues, I had the idea to use iMovie 09 to create a "video file" using a single still image with my audio podcast play in the background. The single image would be consistent for the entire length of the audio. It seems simple...one still image file and one audio file.
    All of my audio files are less than 45 minutes in length. The problem is that when I insert an image in iMovie I can't get it to last for more than 10:00 minutes of my podcast. I've had to drag the same image over several times, extend each image's length to 10:00 minutes until I have enough images to last the full length of the audio file.
    I'm sure there's a simple way to do this with one image, used one time, and have the audio added.
    Anyone understand my situation and have a good idea?

    The most efficient method would be for you to do this in iMovie 6. You can download a version if you don't already have it on your computer. http://supportdownload.apple.com/download.info.apple.com/AppleSupport_Area/Apple_Software_Updates/Mac_OSX/downloads/061-3532.20070807.nq3ER/iMovieHD6.dmg
    Put all your clips into a new iMovie project, in the order you wish them to play. Use the chapters tab and add chapter markers for each clip (except the first one; iDVD will add that one for you). Close iMovie.
    Open an new iDVD project. Use the Media tab, then Movies, to locate your new iMovie. Drag and drop it onto the main iDVD window, taking care not to drop it into a drop zone. You should then see the title of your movie and the two options: Play Movie (which will play all the clips sequentiallly) and Scene Selection (which will take you to submenu(s) where you can select which clip to view).

  • Is there a way to download whole albums with full size photos from picasa to iPhoto without doing it one by one?

    A number of people have sent me albums of photos in picasa.  There doesn't seem to be a way to import the entire album into iphoto other than doing each photo one by one.  Also, when I do each photo, it doesn't appear that I can copy it into a full size photo.
    These are all albums with hundreds of photos.  I think in the old iphoto you could subscribe to an RSS feed to get the whole album into iphoto but I am not sure you can do this anymore.  Can you?
    And if not, is there a way to copy whole albums in?  It would be so time consuming to do them one by one!
    I am using iphoto 9.5.1

    You need to
    1. Download the images to a folder on the desktop.
    It may be possible to download an entire album at a time, but that's a question for a Picasa forum
    2. Then import the folder to iPhoto.

  • I just upgraded to Lightroom CC5 from 4, and the card will only download 1 image from my recent shoot of 10 images. Why can't I see the other images?

    Lightroom 5 will only download one image from my card, when I shot 10. Iphoto doesn't have a problem with it. I never had this problem with Lightroom 4.

    Sort by capture time and the images won't be "scattered all over the place".
    Just show "NEW" photos in the import.
    As Jim said, reformat your card after all your backups are done and verified.

  • Importing images with Lightroom 2  & Camera RAW 4.5

    The following query has been raised with Adobe Technical Support (5 days ago and I am still waiting for a response/reply. They claim to reply within 24 hours but they have not on this occasion......they seem to be ignoring me
    Perhaps a fellow user can help to identify or resolve the problem.
    Operating System:
    Windows XP Professional (Service Pack 3)
    Software:
    Adobe Design Premium CS3 (10.0.1); Photoshop Lightroom 1.4 (which was working fine) and Lightroom 2 (on trial and not working particularly well)
    I am using a trial download of Photoshop Lightroom 2 (with Camera RAW 4.5 in Photoshop CS3).
    I am having a few problems with editing Lightroom 2 images in Photoshop CS3 but I understand that Adobe is currently investigating a solution to this problem.
    I have also noticed another potential problem since I have started to import images from a computer drive to Lightroom 2 and converting the Manufacturers RAW files to DNG (with the option to leave the files at their current location/drive).
    My RAW and JPEG files open ok in Camera RAW (v 4.5) for basic editing and subsequently to Photoshop for more detailed work. The problem is that all my images are now opening as Smart Objects by default in Photoshop CS3, as opposed to opening as a Background layer". (I have not knowingly opted to use the Open as Smart Object option.
    I am not entirely sure how this came about but I have also lost the capacity to edit images with empty Levels adjustment layers or percentage (%) grey fill option).
    I am able to highlight the respective layer and create the empty Levels adjustment layer, change the blend mode to either Multiply or Screen, fill the Layer Mask with Black (Alt & backspace), change the opacity level as desired, select the brush tool and change the foreground colour to white to enable the applicable Dodge or Burn processes.
    Unfortunately, it does not function irrespective of the preferred opacity level. The Dodge or Burn feature is static with no effect on the image.
    I cannot recall any settings to open all files as Smart Objects in Photoshop CS3 but would welcome some help in identifying such a setting if it exists. Alternatively, I would welcome any other suggested methods of correcting the above difficulties.
    The same difficulties are evident when I try to use the Dodge or Burn features via the Edit and Fill option with a percentage of Grey and the Overlay Blend Mode.
    The "Common Denominator" of the above difficulties appear to be Lightroom 2 and Camera RAW 4.5 (individually and or collectively) and now I am stuck between a rock and a hard place.
    Are any other users experiencing similar issues or have any suggestions about how I might correct or resolve these problems? ......
    I am not afraid of hearing or accepting that the "Dummy Factor" has played some part or how I may release myself from the said "Dummy Factor".....any help is welcome help.
    Adobe Technical Support seems to be ignoring me......I wonder why?
    Regards
    Bob Wallace

    Essentially you are wrapping the raw image data into a special type of layer, a "smart object". You can then revisit and fine tune the Camera Raw conversion as often as you want and take advantage of working directly on the raw data in its pre-Photoshop purity. You can also apply to this smart object layer a number of Photoshop adjustments and filters - and again redo and fine tune them as often as you wish.
    You'll find them explained in a number of recent books. I know Scott Kelby is keen on them, there are examples on Russell Brown's site, and my own book last year on B&W strongly advocated their use.
    Have a play.
    John

  • When trying to upload pictures from my camera I get this message although I have uploaded from the same camera in the pastiPhoto cannot import your photos because there was a problem downloading an image.

    When trying to upload pictures from my camera I get this message although I have uploaded from the same camera in the past, "iPhoto cannot import your photos because there was a problem downloading an image."

    Can you access the images with Image Capture (in your Applications Folder) ?

  • I cannot import photos from any device to my iphoto program- the error message statesphotos cannot import because there was a problem downloading an image.  I cannot identify the image that is the problem.

    I cannot import photos to my iphoto from any of my devices.  The error message reads - iphoto cannot import your photos because there was a problem downloading an image.  I have deleted the last images- this did not help.  any suggestions?

    Details please
    What version of iPhoto? Of the OS? what devices are you haveing problems with? can you download teh photos to a desktop folder using image capture (in your applications folder) and import from there - or open with priview from there?
    LN

Maybe you are looking for

  • Uploading about 2GB file into database

    Hello, I want to upload a file of about 2GB size in the database. I am working on Struts framework and with Postgres8 and Oracle8i as database. When I try to upload it through my application it throws "Out of heap memory" error. Can anyone help me ou

  • Apps and itunes

    How can I manage my apps on itunes? It is not showing the apps in the Library category, and I can't change anything like the location on the homepage when I go into the device, what should I do?

  • OSStatus error -4960

    Tried sorting bookmarks using Internet Cleanup. Got OSStatus error -4960. Anyone who can shed light on this and a fix?

  • Sles11 named as OES2-Backup-DNS?

    Hi, I was wondering if it would be possible to use the named service of a Sles11 to work as a backup server for our OES2 DHCP/DNS setup? I mean, novell-named is not all that different to the default Linux one, right? If so, how would I go about doing

  • CALL transaction using generic user.

    Hi experts, I have a   CALL TRANSACTION, which code is: 'ME54' USING BDC_TAB MODE 'E' UPDATE 'S'. I have previosly defines the BDC_TAB. Is is a backgroud process executes with an event. The sy-uname there is the same as the user that has lauched the