Problem in Saving Captured Images.

Hi all,
I am trying to save the images which are captured by the webcam. I am getting the
error as
JPEGEncodeTest.java:32:cannot resolve symbol
Symbol: method getImage()
location: class JPEGEncodeTest
image = getImage(); (Error)
I am trying to compile the code for saving separately first and then attach this piece of code to the main program. And the code is
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.FileOutputStream;
import java.io.OutputStream;
import com.sun.image.codec.jpeg.JPEGEncodeParam;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
import com.sun.image.codec.jpeg.JPEGCodec;
public class JPEGEncodeTest
public static void main(String[] args)
throws Exception
OutputStream out = null;
BufferedImage image = null;
try {
     image = getImage();
// Open output file.
out = new FileOutputStream("test.jpg");
// Create jpeg encoder.
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
// Set quality.
JPEGEncodeParam encodeParam = encoder.getDefaultJPEGEncodeParam(image);
encodeParam.setQuality(0.7f, false);
// Encode.
encoder.encode(image, encodeParam);
// Close output file.
out.close();
} catch(java.io.IOException io)
     System.out.println("Java IO Exception");
If anyone has encountered the getImage function not to work and have figured it out, please let me know. Or If anyone has any suggestions in this issue, please let me know. I am really thankful to all of you as I need this to work as soon as possible and am unable to think of how to solve it.
Sorry for the inconvenience.
In Advance thanks to all of you.
padmaja.

according to the error posted, and the code posted. there is no method getImage();
image = getImage();//you have this line, this is where error is, Where is getImage()???Is getImage() in a different class???
you need something like this in the code above....
public Image getImage(){
.....add the above code to your posted code then, what is the error.

Similar Messages

  • Problem in saving the image into SQL database..

    Hello,
    In my application I have to save image file (say jpg) into the database and retrieve back and display it on the applet. I am through with grabbing the pixels of the image & sending the pixel array to the servlet but I am struck in how to store the image into the database and retrieve the same.
    Can anybody please help me in this regard... its really urgent...
    Thanks in advance
    Swarna

    Hello.
    I've been researching this problem (saving images in a MySQL database) in order to accomplish a task I was assigned to. Finally I was able to do it. I'd be glad if it will be of any use.
    First of all: the original question was related to an applet. So, the post from rkippen should be read. It says almost everything, leaving the code job for us. Since I managed to write some code, I'll put it here, but I'm not dealing with the byte transferring issue.
    To obtain a byte array from a file I'd open the file with FileInputStream and use a loop to read bytes from it and save them into a ByteArrayOutputStream object. The ByteArrayOutputStream class has a method named �toByteArray()� which returns an array of bytes (byte [] b = baos.toByteArray()) that can be transferred in a socket connection, as said by rkippen.
    My problem was to save an image captured by a web camera. I had an Image object, which I converted into a byte array and saved into the database. Eventually I had to read the image and show it to the user.
    The table in the MySQL database could be:
    CREATE TABLE  test (
      id int(11) NOT NULL auto_increment,
      img blob NOT NULL,
      PRIMARY KEY  (id)
    )I had problems trying to use the �setBlob� and �getBlob� methods in the Statement object, so I used the �setBytes� and �getBytes� methods . In the end, I liked these methods most because they where more suitable to my application.
    The database operations are:
        public int insertImage(Image image) throws SQLException {
            int id = -1;
            String sql = "insert into test (img) values (?)\n";
            PreparedStatement ps = this.getStatement(sql);  // this method is trivial
            byte [] bytes = this.getBytes(imagem); // * see below
            ps.setBytes(1, bytes);
            ps.executeUpdate();
            id = ps.getGeneratedKeys().getInt(0); //Actually I couldn't make this line work yet.
            return id;
        public Image selectImage(int id) throws SQLException {
            Image img = null;
            String sql = "select img from test where id = ?\n";
            PreparedStatement ps = getStatement(sql);
            ps.setInt(1, id);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                byte [] bytes = rs.getBytes(1);
                img = this.getImage(bytes); // * see below
            return img;
        }* If the bytes are read directly from a file, I think it is not necessary to convert it into an Image. Just send the bytes to the database method would work. On the other hand, if the image read form the DB will be written directly into files, the bytes obtained from rs.getBytes(1) would be enough.
    The image operations are:
        public byte [] getBytes(Image image) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ImageIO.write(this.getBufferedImage(image), "JPEG", baos);
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            return baos.toByteArray();
        public Image getImage(byte [] bytes)  {
            Image image = null;
            ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
            try {
                image = ImageIO.read(bais);
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            return image;
        public BufferedImage getBufferedImage(Image image) {
            int width = image.getWidth(null);
            int height = image.getHeight(null);
            BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
            Graphics2D g2d = bi.createGraphics();
            g2d.drawImage(image, 0, 0, null);
            return bi;
        }That's it. I hope it is useful.

  • Problem w/saving simple image as .png

    Hello:                                                                                                                            Level: Newbie'ish   OS: Win7 64bit   PS: CS6
    I have been making a simple image of a 300 by 100 rounded rectangle and then adding various layer styles. Basically I am makeing mobile headers which will be used for mobile websites.
    Today I was reviewing  a few that I have made and noticed that when I open them in their .png format and then create a selection around one (Ctrl + Click) that the lower right coner is not being selected as rounded but as a point and so when I copy and then paste it into a new document it has three rounded corners and one somewhat visible pointed corner.  ?? ??
    The file has a BG layer and two shape layers (or sometimes just one shape layer). I select the layers and then merge them together and turn off the BG layer beofore I save them for the web. I have also tried just saving the file as a .png w/out merging the layers but no matter how I go about saving the file(s) most of the time one corner is saved w/that annoying and imperfect sharp corner.
    Any ideas? Your time is greatly appreciated ~ Thanx a Bunch!!

    Hey c.pf...
    sorry for just getting back ~ the holiday season has me run'n Crazy.
    any way, i figured out my problem. i hadn't realized that i accidentally clicked the outer glow option and it was so faint that i couldn't see it all that well or actually ~ at all until i went back through the LS ...
    so, when i would save the image (mobile header) it was including or making room for the outer glow
    funny how something so simple can be overlooked.
    well, sorry for bothering ya over nothing ~ but i really appreciate your willingness to help me out
    hope all is well!! thanx again!

  • Problem with saving Contact Images?

    In the process of creating a new contact, I took a photo of someone I probably won't see for awhile instead of choosing an existing photo. But when I look for under "camera roll"... I don't see it there. But it still happens to be under the contact. I know you can extract the photos from my computer, but when I tried looking for it in the 100apple folder, it wasn't there.
    My question, do you know where I can find the image I took after choosing "take image" under the contact menu? Especially if I don't use Outlook for sync my contacts... Thanks!

    docs44 wrote:
    I think you misunderstood what the person was saying. looking in the 100App folder doesn't mean it is jailbroken. Mine's not and I can access that. When connect your iPhone to the computer you get the message asking if you want to view the files. Or when it's connected you can go to "my computer" on a PC and access the photos that way too. If you choose to then you can access those files which have photos. The same photos as the camera roll.
    Thank you for the clarification.
    But yes, since he took the photo from the Contacts App and assigned directly from there as opposed to taking a pic with the Photo app and then assigning with an existing photo, the photo doesn't go to the camera roll but just to the contacts database (which is off limits to users). The best he can do is sync and get it from his Address book (though much smaller).

  • Saving an image in Root folder of tomcat

    Hello,
    i have an urgent problem with saving an image in the root folder of tomcat, which I want to do without having to specify the entire path.
    I have created a class, which i use as a bean in a jsp to save an image to the tomcat root folder.
    If I use the following command, the image is saved:
    ChartUtilities.saveChartAsJPEG(new File(
    "C:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/trader/images/charts/1.jpg"), chart, 550, 260);
    However, I should be doing it like this, which doesn't work and throws me an IO exception:
    ChartUtilities.saveChartAsJPEG(new File("images/charts/1.jpg"), chart, 550, 260);
    Cheers

    Didn't we have this discussion in another thread? You can't give something urgently. It's semantically anaphoricular.

  • WDS Capture Image Blank Screen with Cursor

    Hey everyone, happy Friday and Happy Sysadmin Day!
    Not super happy for myself unfortunately! I'm having a problem with a Capture Image in WDS. I have a Sysprepped Dell 6440 running Windows 7 x64.I've created a Capture Image in WDS from a boot image with drivers injected and without drivers injected, but every time I boot from PXE, it gets to the windows loading screen, and then it just shows a blank screen with a cursor.I'm using Microsoft's OpenLicense ISO as a base for the boot.wimI can't find any solution that works. I've tried mounting and unmounting the WIM, restarting WDS, etc. This is getting really frustrating as I'm so close to having these images ready.The blank screen won't do anything, won't open a cmd with Shift+
    F10 or anything. I've also tried booting on a different machine and it does the same thing.Any suggestions are...
    This topic first appeared in the Spiceworks Community

    HI @Moonrod ,
    Welcome to the HP Forums!
    It is a super place to find answers and information!
    For you to have the best experience in the HP forum I would like to direct your attention to the HP Forums Guide Learn How to Post and More
    I grasp you were unable to do a refresh you PC as you received the message that the drive was locked.
    Please refer to my post Re: Can't refresh or reset windows 8.1 because drive is locked
    Here is a link from the windowsclub.com that may also be informative.
    Fix: The drive where Windows is installed is locked.
    Best of Luck!
    Sparkles1
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos, Thumbs Up" on the bottom right to say “Thanks” for helping!

  • Where is my captured image/ file saved?

    Captured images appear in the Sprout Gallery.
    These are saved to the Captured Images folder in the Pictures library: This PC/Pictures/Captured Images.
    I work for HP, supporting the HP Experts who volunteer their time and technical knowledge to help others.

    What an amazing product!
    Signature:
    HP TouchPad - 1.2 GHz; 1 GB memory; 32 GB storage; WebOS/CyanogenMod 11(Kit Kat)
    HP 10 Plus; Android-Kit Kat; 1.0 GHz Allwinner A31 ARM Cortex A7 Quad Core Processor ; 2GB RAM Memory Long: 2 GB DDR3L SDRAM (1600MHz); 16GB disable eMMC 16GB v4.51
    HP Omen; i7-4710QH; 8 GB memory; 256 GB San Disk SSD; Win 8.1
    HP Photosmart 7520 AIO
    ++++++++++++++++++
    **Click the Thumbs Up+ to say 'Thanks' and the 'Accept as Solution' if I have solved your problem.**
    Intelligence is God given; Wisdom is the sum of our mistakes!
    I am not an HP employee.

  • JTextPane -captured image refreshing problem

    Dear All,
    In my application it is necessary to capture the
    screen and save it as jpeg and display the same in a JTextPane using <img> tag.
    I have made use of com.sun.image.codec.jpeg to save the image and it works fine.
    After starting the application the
    first picture is displayed well but the other pictures though get saved is not displayed in the JTextPane.Only the previous picture remains.
    I have made use of new Instance of TextPane each time.All the captured images are saved in the same name say "images/screenshot.jpg" one at a time.
    Please tell me what would be the problem.
    Expecting your reply
    Thanks and Best Regards,
    AnushaJv

    Try to remove text from the document and set it again.
    JtextPane pane;
    Document doc=pane.getDocument();
    String content=doc.getText(0,doc.getLength());
    doc.setText("");
    doc.setText(content);
    best regards
    Stas

  • Labview IMAQ VI for capturing images and saving with incremental file names

    Hello,
    I am using LabView 7.1(IMAQ) to capture images with NI's PCI 1426 card, and a JAI CV-M2 camera. Now, with the example VI's like LL Grab, or LL Sequence, or Snap and Save to File.vi, I can capture the images. But what I actually want is to capture images continuously and keep saving them with a sequentially incrementing file name.
    I have tried to modify the Snap and Save to File.vi  by adding a 'for loop', so as to run this for required number of images. This works okay, but I can't really change the file name after every image. However, I'm not confident with this method either. I think it would be better to use the buffer itself, as is given in LL Grab.vi and somehow save images from the buffer. I think this would be faster ?
    In any case, any ideas as to how I should go about implementing auto-incrementing of the file name ?
    Any help will do. 
    Thanks.
    - Prashant

    Hi,
    Thanks a lot for replying. 
    I tried using this in the VI i was working with, but using the "build path" vi doesnt seem to work. If I use just the base path from user's input, it works, but then again it keeps overwriting the images into one file rather than giving each file a new name. I'm attaching the vi. 
    Please take a look and tell me where i'm going wrong.
    Thanks again.
    Attachments:
    LL Sequence_mod.vi ‏62 KB

  • Problem in saving image to jpg

    Hello.
    I've got a problem in saving a LabView Picture in a jpg File.
    The picture id grabbed from a DirectX Livestream from a camera.
    Then I want to save it in a jpg file using the Standard LabView Functions.
    But all I get is an empty jpg File and an error:
    Check_Data_size.vi
    Error 1
    I'm using LabView 7.1.
    Has anybody got an idea how to solve the problem?

    No.  You can save a gray image to jpg, but I has to be 24 bit.
    Try save your data to bmp.  If you got the same problem, that means you fail to wire correct data format to the LabVIEW VI you're using.
    George Zou
    http://gtoolbox.yeah.net
    George Zou
    http://webspace.webring.com/people/og/gtoolbox

  • I am using adobe photoshop cs6. I am facing a problem. When i save any image as "save for web". After saving image it show cropped. An image show many parts of the image after saving the image. Please help me. Thanks in advance.

    I am using adobe photoshop cs6. I am facing a problem. When i save any image as "save for web". After saving image it show cropped. An image show many parts of the image after saving the image. Please help me. Thanks in advance.

    Just go back in photoshop and use the Slice Select tool, then just click and select the slice and hit delete - if you're not sure which one is the active slice just right click and find the one that has the Delete Slice option.
    It's possible you either added the slices by accident or if you received it from someone they just had the slices hidden. For the future, you can go to View > Show > Slices to display (or hide) slices.

  • Problem deploying captured image

    I'm testing our new SCCM 2012 and specifically OSD and deploying a captured image. The image is captured on a separate MDT config.
    What I'm seeing with this image deployment is that about 90% of the times it ends with a 80070002 TS error. Examining the smsts.log shows the following:
    Successfully completed the action (Setup Windows and ConfigMgr) with the exit win32 code 0
    So this step seems to go fine and and then the State Restore step starts and the computer reboots to the full OS.
    The group (State Restore) has been successfully started
    But then I don't know what happens, non of the following steps are run, for example there's application install and so forth. It seems to parse through the remaining steps but doesn't run them and then ends with Gather Logs and stateStore on Failure.
    I just can't see from smsts.log what the problem would be, what other logs should I look in to find out what's going on?

    Seen that many times when doing deployments, but not on capture mentioned. In that case the error is a known bug. Workaround is to add 2 Task Sequence Variables. Unfortunately R2 is needed for that.
    -SMSTSDownloadRetryCount = 5
    -SMSTSDownloadRetryDelay = 15
    Just have a look at my blogpost for more information on this:
    http://henkhoogendoorn.blogspot.nl/2014/07/osd-ts-fails-during-package-download.html
    My blogs: Henk's blog and
    Virtuall | Follow Me on:
    Twitter | View My Profile on:
    LinkedIn

  • I am having problems saving certain images

    I am having problems saving certain images. For example, on Ebay while viewing an auction item, when you click on the image to view the larger picture it opens in a new window. With Internet Explorer, you can "right-click" and "save picture as". With Firefox 3.6.9 the "save picture as" option is not availabale. Other options such as save "save page as" are available, but not "save as," or "save picture as." Any ideas? Thanks

    I have found a solution to the problem. Apparently there is an addon to fix this. Had no idea a specific google search for "trouble saving images on ebay" would turn up anything.
    https://addons.mozilla.org/en-US/firefox/addon/13802/

  • Problem with capturing image

    http://1drv.ms/1jWJ5a3
    Problem with capturing image. Logs included.
    Also after deploying letters are swapped. System is on D drive, and data on C drive.
    Any idea ?

    Based on the logfiles:
    SMSSITECODE=K01
    SMSMP=SCCM.kolubara.local
    you could also use DNSSUFFIX=kolubara.local
    More on CCMSetup parameters can be found here
    http://technet.microsoft.com/en-us/library/gg699356.aspx. Use client.msi parameters in your task sequence separated by spaces, so that your Setup Windows & Configuration Manager Client -step looks like this:

  • Problem in Saving Image Code

    Hi, I'm been dealing with this code that should be saving an image as a JPEG format.
    public static void saveAsJPEG(RenderedImage image, String file)
    throws java.io.IOException {
    String filename = file;
    if(!filename.endsWith(".jpg"))
    filename = new String(file+".jpg");
    OutputStream out = new FileOutputStream(filename);
    JPEGEncodeParam param = new JPEGEncodeParam();
    ImageEncoder encoder = ImageCodec.createImageEncoder("JPEG", out, param);
    encoder.encode(image); out.close(); }
    However, when I compile the code, there's an error come out : com.sun.image.codec.jpeg.JPEGEncodeParam is abstract; cannot be instantiated
    I really can't figure out the meaning of this exception. So, would somebody kindly tell me what is wrong with the code?
    And another question is : What package is the ImageCodec located? Thanks a lot :)

    try this out and let me know;
    public static void saveAsJPEG(BufferedImage image, String file)
    throws java.io.IOException {
    String filename = file;
    if(!filename.endsWith(".jpg")) filename = new String(file+".jpg");
    OutputStream out = new FileOutputStream(filename);
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out); // Create JPEG encoder
    JPEGEncodeParam jpegParams = encoder.getDefaultJPEGEncodeParam(image);
    jpegParams.setQuality(1.0f, false); // Set quality to 100% for JPEG
    encoder.setJPEGEncodeParam(jpegParams);
    encoder.encode(image); // Encode image to JPEG and send to browser
    //JPEGEncodeParam jpegPparams = new JPEGEncodeParam();
    //ImageEncoder encoder = ImageCodec.createImageEncoder("JPEG", out, jpegParams);
    //encoder.encode(image);
    out.close(); }

Maybe you are looking for

  • IPod not putting out sound on right headphone

    As of yesterday, my iPod is not producing any sound through the right headphone. I've tried my headphones on other devices and they work, and also tried other headphones on my ipod and the right headphone still has no sound. It seems like a problem w

  • Is there a way to change the font-size in the html element

    I notice that by default, the font-size in the boilerplate.css file is set to 100%. Is there a way to set it to something else such as 62.5%? I would like to see exactly what my content will look like in my WordPress theme. I build my themes using a

  • XML Data File With Namespace

    Hi, I'm trying to create a template with the below xml data file. However, I'm struggling to get any of the field to show up in the report output. Does any have the same issue? <ns0:getCommunityPhaseMasterResponseElement xsi:type="ns0:CVO_CommunityPh

  • My ipod resets every few minutes

    I dropped my ipod (mini first gen.), and it froze, so i did the quick reset, and the apple sign showed up on it for a long time, and then the language selection screen came up, and my ipod completely reset, with all my music deleted. After a few minu

  • What is propertytree with name "workflow" used for

    Hello EH&S friends, Does anybody know where the propertytree called "workflow" is used? Also background information in the process to use this would be helpfull. Thanks in advance. Regards, Pascal