Gif images string into database

Hi All,
Can I store and retrive GIF files(or may be JPEG files) into Oracle8i database? Basically I got a web site where user can Upload his image. When he uploadeds, I want to store it in Oracle DB and retrive and return to site whenever requested. How can i do this using SQL and or PL/SQL ? Also are there any tips to get the best performance of the whole transaction? Please advise. Some examples, URLs will be of much much use.
Many Thanks
Sandeep

For storing images, you can use BLOB.
See http://technet.oracle.com/docs/products/oracle8i/doc_library/817_doc/appdev.817/a76936/dbms_lob.htm#998100
for doc on LOBs
Hi All,
Can I store and retrive GIF files(or may be JPEG files) into Oracle8i database? Basically I got a web site where user can Upload his image. When he uploadeds, I want to store it in Oracle DB and retrive and return to site whenever requested. How can i do this using SQL and or PL/SQL ? Also are there any tips to get the best performance of the whole transaction? Please advise. Some examples, URLs will be of much much use.
Many Thanks
Sandeep

Similar Messages

  • Data Type for saving Base64 image string into SQL database

    Hi Team! I have image base64 string to be save into sql database. I use Varchar(MAX) data type. The problem is there are certain image string that cannot be enter (paste) into the table (due to the size) then i need to resize the image then i can paste
    the string into the table. How to make all image string size be able to be save in the table? Or there is limit on the image size to be save into the table? I'm using mssql 2008. Thanks a lot.

    There is a limit of 2GB. Which means that the actual image size must be less, since you encode the image in Base64 for some reason.
    Now, "pasting" strings is not the normal way to store data in an SQL Server database, so the question is a little funny. Normally data is stored in a database through a program of some sort. One way is to use OPENROWSET(BULK) as HuaMin suggested.
    Here is a link to a simple example of how to do it from .NET:
    http://www.sommarskog.se/blobload.txt
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Insert large Image object into Database

    Hello
    I have a large (!MB) image which needs to be stored in a database BLOB column, and I'm running out of memory with my naive code..
    Nothing other than the code is within my control. I cannot change my heap size; I have no file-system, so cannot write the image.
    The awt.Image is created and drawn elsewhere in the application. My thought was to create a byte stream and have that inserted chunk-by-chunk, but I just can't find out how to do this in a limited time.
    Any help would be much appreciated.
    Lee

    leegee23 wrote:
    Thanks for your help. Have tried this:
    ImageInputStream is = ImageIO.createImageInputStream(gif);But got null. The docs read:
    Returns an ImageInputStream that will take its input from the given Object. The set of ImageInputStreamSpis registered with the IIORegistry class is queried and the first one that is able to take input from the supplied object is used to create the returned ImageInputStream. If no suitable ImageInputStreamSpi exists, null is returned.
    Am I barking up the wrong tree?I think you're on the right track. A quick browse found that an ImageWriter (GIFImageWriter) can be used to write an image to an output stream (use ImageIO.createImageOutputStream()), and then you can probably use PipedInputStream/PipedOutputStream to obtain an inputStream that you can pass to your JDBC driver to store the blob.
    That's just from reading Javadocs though, I'm not sure how to connect the dots.
    And also, make sure you post a reference to this thread on the new one you created. You wouldn't want people to waste time answering that thread if there's an answer here already, or vice versa.
    Edit: I was thinking specifically of using a GifImageWriter constructed with a OutputStreamImageOutputStreamSpi that was passed in a PipedOutputStream which you would in turn connect to a PipedInputStream which you would pass in to the JDBC method.
    But I'm not sure, it looks like even then it either uses a memory cache or a file cache. When you have compression, the writer will typically need to have access to all the bytes of the image before starting to write. It would be a two-pass algorithm, most likely. Which basically means you might have memory issues anyway.
    Edited by: endasil on 22-Sep-2009 1:12 PM

  • Importing text file into database

    Hi again,
    Could anyone give me any pointers on how to take a text file or csv file (or any other delimeted text file) and read the contents into java and then use the read in data to then insert the delimeted data into the table.
    i assume i have to read the delimeted data into a variable then parse the complete string with the delimeter and split the data up maybe in an array. Maybe this is completely wrong, im really unsure.
    any help would be greatly appreciated even a point in the right direction would be great :)
    kind regards.

    Well, atleast i dont know of a single method, which does this kind of nonhomogenous task!! Its not hard to impliment what you want-->
    //open the text file using FileInputStream & get the contents in a String variable
    //Tokenise it
    StringTokenizer st=new StringTokenizer(your_string_retrieved_from_file,delimiter);
    int i=0;
    while(st.hasMoreTokens())
    i++;
    //SQL Statement that inserts a string into database table(integer, varchar2)
    insert into test_table values(i,st.nextToken());
    Unless you are talking about putting the tokens as coloums in a single row, i dont find why this is a problem & if you are actually doing the above case, then you might wanna rethink your design

  • Looking for comprehensive program to create pdf file from gif image

    Hello,
    I'm looking for a program that can transform gif image file into pdf file. It is very importent to keep the same quality of the output document as the original image.
    I've seen Bridge CS5 in action and was very much disapointed, because the original gif image had 2 colors: black and white, took 60k Byte A4 paper size. But the output pdf file became somehow to 700k Byte size. When our proffi tried to lower the ppi or quality bar there was direct impact on the image quality.
    Long time ago Photoshop was able to export images as pdf files and one of the options of the pdf file was to keep the original image as gif, not as jpeg. Because jpeg is very costy format for black-white images and no-one wants to waste memory in vain, so I do not like to save pdf files of 1MB size for an image that takes 100k in gif.
    I do understand that nowdays using Photoshop to save pdf files is not the option anymore, isn't it ?
    What program can you suggest me to use ? I still prefer to use Adobe products, as long as I can, through I'm starting to get scared of sharp decline in quality.
    Thank you in advance.
    sincerely,
    Al

    No, I didn't. The last time I saw it, it was looking just as a regular Reader with a little more options and with an addon to MS-Office, to allow to save MS documents to pdf from inside MS-Office user interface products, and frankly, I do not highly admire there products at all, so I do not have MS-Office installed. But it was also long time ago. If the situation did changed since than,  I will try it.
    Thank you very much.
    I've just tried the Acrobat. It worked great ! Thank you. Just not all the images have options how to save them in pdf file, but that's ok for now

  • Storing image files (.gif)  into database from sql plus

    dear all
    I have to store image files into a table with BLOB attribute.
    What will be the insert command to insert a .gif file into the database.
    thanks.

    You can use DBMS_LOB.LoadFromFile, I assume you would load these as a BLOB.
    The documentation can be found on technet at
    urlhttp://technet.oracle.com/docs/products/oracle9i/doc_library/901_doc/appdev.901/a89852/dbms_20b.htm#1009007
    [\url]
    An alternative would be to use java to read the file from the file system, and serve it up as a CLOB or BLOB, and INSERT it into the database from there.
    Good Luck,
    Eric Kamradt

  • Save images into database

    hello, i have been fighting with this for some days, i have a picture that i load with de filerence.load method. and then,
    i use the filereference.data to show the picture into the image control.
    i need to save the image into database, but i can't. i don't know how i can convert the bytearray into hexa string or binary!!!

    Hi Sai,
           I am getting the error ArgumentError: Error #2015: Invalid
    BitmapData. When I am trying to change the image into byteArray using
    BitMapData.
          Below is the code i am using for this scenario. I am trying to get
    byteArray of the image after the image is completely loaded in the
    onComplete().
    private function initFunction(event:Event):void{
    uploadFile =new FileReference();
    imgTypes=new FileFilter("images(.JPG,.JPEG,.PNG,.GIF)",*
    ".JPG;.JPEG,.PNG;.GIF;"*);
    private function browseFile():*void
    uploadFile.addEventListener(Event.SELECT, onFileSelected);
    *try
    uploadFile.browse();
    catch(err:Error)
    logData(err.message);
    private function onFileSelected(event:Event):*void
    uploadFile.addEventListener(ProgressEvent.PROGRESS, onProgress);
    uploadFile.addEventListener(Event.COMPLETE, onComplete);
    uploadFile.load();
    private function onProgress(event:ProgressEvent):*void
    logData("Loaded " + event.bytesLoaded + " of " + event.bytesTotal + *"
    bytes."*);
    private function onComplete(evt:Event):*void
    logData("File was successfully loaded.");
    *//image.source = uploadFile.data;
    image.source=uploadFile.name;
    Alert.show("image source:"+image.source);
    var bitmapData:BitmapData = new BitmapData(image.width,image.height);
    var ba:ByteArray = png.encode(bitmapData);
    Alert.show("bytes loaded"+ba);
    Thanks,
    Ravi.
    On Sat, Nov 20, 2010 at 9:19 PM, ravindharreddy Baddam <

  • How to insert a image file into oracle database

    hi all
    can anyone guide me how to insert a image file into oracle database now
    i have created table using
    create table imagestore(image blob);
    but when inserting i totally lost don't know what to do how to write query to insert image file

    Hi I don't have time to explain really, I did have to do this a while ago though so I will post a code snippet. This is using the commons file upload framework.
    Firstly you need a multi part form data (if you are using a web page). If you are not using a web page ignore this bit.
    out.println("<form name=\"imgFrm\" method=\"post\" enctype=\"multipart/form-data\" action=\"FileUploadServlet?thisPageAction=reloaded\" onSubmit=\"return submitForm();\"><input type=\"FILE\" name=\"imgSource\" size='60' class='smalltext' onKeyPress='return stopUserInput();' onKeyUp='stopUserInput();' onKeyDown='stopUserInput();' onMouseDown='noMouseDown(event);'>");
    out.println("   <input type='submit' name='submit' value='Submit' class='smalltext'>");
    out.println("</form>"); Import this once you have the jar file:
    import org.apache.commons.fileupload.*;Now a method I wrote to upload the file. I am not saying that this is correct, or its the best way to do this. I am just saying it works for me.
    private boolean uploadFile(HttpServletRequest request, HttpSession session) throws Exception {
            boolean result = true;
            String fileName = null;
            byte fileData[] = null;
            String fileUploadError = null;
            String imageType = "";
            String error = "";
            DiskFileUpload fb = new DiskFileUpload();
            List fileItems = fb.parseRequest(request);
            Iterator it = fileItems.iterator();
            while(it.hasNext()){
                FileItem fileItem = (FileItem)it.next();
                if (!fileItem.isFormField()) {
                    fileName = fileItem.getName();
                    fileData = fileItem.get();
                    // Get the imageType from the filename extension
                    if (fileName != null) {
                        int dotPos = fileName.indexOf('.');
                        if (dotPos >= 0 && dotPos != fileName.length()-1) {
                            imageType = fileName.substring(dotPos+1).toLowerCase();
                            if (imageType.equals("jpg")) {
                                imageType = "jpeg";
            String filePath = request.getParameter("FILE_PATH");
            session.setAttribute("filePath", filePath);
            session.setAttribute("fileData", fileData);
            session.setAttribute("fileName", fileName);
            session.setAttribute("imageType", imageType);
            return result;  
         } And now finally the method to actually write the file to the database:
    private int writeImageFile(byte[] fileData, String fileName, String imageType, String mode, Integer signatureIDIn, HttpServletRequest request) throws Exception {
            //If the previous code found a file that can be uploaded then
            //save it into the database via a pstmt
            String sql = "";
            UtilDBquery udbq = getUser(request).connectToDatabase();
            Connection con = null;
            int signatureID = 0;
            PreparedStatement pstmt = null;
            try {
                udbq.setUsePreparedStatements(true);
                con = udbq.getPooledConnection();
                con.setAutoCommit(false);
                if((!mode.equals("U")) || (mode.equals("U") && signatureIDIn == 0)) {
                    sql = "SELECT SEQ_SIGNATURE_ID.nextval FROM DUAL";
                    pstmt = con.prepareStatement(sql);
                    ResultSet rs = pstmt.executeQuery();
                    while(rs.next()) {
                       signatureID = rs.getInt(1);
                    if (fileName != null && imageType != null) {
                        sql = "INSERT INTO T_SIGNATURE (SIGNATURE_ID, SIGNATURE) values (?,?)";
                        InputStream is2 = new ByteArrayInputStream(fileData);
                        pstmt = con.prepareStatement(sql);
                        pstmt.setInt(1, signatureID);
                        pstmt.setBinaryStream(2, is2, (int)(fileData.length));
                        pstmt.executeUpdate();
                        pstmt.close();
                        con.commit();
                        con = null;
                if(mode.equals("U") && signatureIDIn != 0) {
                    signatureID = signatureIDIn.intValue();
                    if (fileName != null && imageType != null) {
                        sql = "UPDATE T_SIGNATURE SET SIGNATURE = ? WHERE SIGNATURE_ID = ?";
                        InputStream is2 = new ByteArrayInputStream(fileData);
                        pstmt = con.prepareStatement(sql);
                        pstmt.setBinaryStream(1, is2, (int)(fileData.length));
                        pstmt.setInt(2, signatureID);
                        pstmt.executeUpdate();
                        pstmt.close();
                        con.commit();
                        con = null;
            } catch (Exception e) {
                con = null;
                throw new Exception(e.toString());
            return signatureID;
       }

  • How can I insert an image(JPG) into a SQL database?

    I have written an application to perform some tests in the lab.  After gathering the data I store it into a SQL Server.  I successfully managed to export all my raw numbers and calculations to the DB.  However I have not been able to export a screenshot of the Front panel.  I can write the screenshot to a JPG file just fine.  The problem is putting the image (binary data) into the DB.
    So from what work I've managed to do, two questions come to mind:
    1)  Is there a way to compress the screenshot, using standard JPG compression, without actually writing out to a file.  ie:  Just have a binary stream of the compressed image that I can write to the SQL database.
    2)  Even if I don't use compression, I can't write any kind of data that appears as an image.  What kind of data do I need to be writing from LabView to store it properly in an 'image' or 'binary' type field in a SQL database?  I am not looking for answer "binary data."  Nor do I want the answer that is stated in the Help file for the DB Connectivity Toolkit(type - Data Cluster).  What I need is to know what kind of conversions I need to do on the image data that comes out of the FP.GetScaledImage.
    I am using LabView 8.0 and have the Database connectivity toolkit.  We are running SQL Server 2000 and 2005.

    I also hit this limit.  In the end I just wrote the JPGs to disk, and stored the file path in the DB.  Not the ideal solution, I know.
    I'm trying to remember now, exactly what the problem was.  You're right to say the image data type should handle up to 2GB.  I think in the end, it was an issue of the LabView toolkit not playing well with newer versions of SQL Server, which have the image type.  Re-reading the error though, it sounds like it might be an issue with the ODBC driver.  FYI, 8KB used to be the max size for the largest types in SQL Server (I think binary in 2000).  I suspect this limit was coded into the driver or LabView, and can't handle the newer, larger types.
    That being said, the LabView DB toolkit was either written poorly or written a long time ago.  It has issues with generating SQL queries that have the proper quotes.  For example, if your column names have spaces in them, the toolkit will be unable to generate a valid query, without some modification of the toolkit *.vi's.  Images in a database is not a new concept and not new to me.  I've never used a language where it was more complicated or difficult to get working.  Unless you absolutely have to, I'd work out a way to just store the JPGs to disk, with the path in the DB.  Spending too much time on this defeats the purpose of using LabView.
    If NI decides to update the DB toolkit, then it might be worth giving it a try again.
    In case any NI people are reading this, this is a not so subtle hint that you need to update the DB toolkit to support modern DB features.  Especially, if NI is charging $1000 for it.

  • (Urgent)help: how to use sdk add a gif image into a pdf document

    I had use sdk plus-in add a new button of mine,if I click the button,a gif image will be inserted into the current page of pdf document
    My questions:
    one : When I clicked the button,there was a warnning box said:the image has not enough data.I don't known why?
    two : How can I be sure the position of the image which I inserted? and how to change it's position?
    three:  how to use sdk get the content of the document?

    hi Leonard:
    I do it like you said, but
    Why my image can not display in the pdf.
    code is:
    //====================================================================
    const ASInt32 theImageByteSize = IMG_WIDTH * IMG_HEIGHT;
    char* buff = new char[theImageByteSize];
    PDEImage volatile pdeImage = NULL;
    PDEImageAttrs pdeImageAttrs;
    PDEColorSpace pdeColorSpace;
    ASFixedMatrix imageMatrix;
    memset(&pdeImageAttrs, 0, sizeof(PDEImageAttrs));
    int hdl = _open(ImagePath, _O_RDONLY | _O_BINARY, _S_IWRITE | _S_IREAD);
    if (hdl == -1)
         AVAlertNote("[%s] create fail !!!!") ;
    if (_read(hdl, buff, theImageByteSize) == -1)
         AVAlertNote("read image fail!") ;
    pdeImageAttrs.width = IMG_WIDTH;
    pdeImageAttrs.height = IMG_HEIGHT;
    pdeImageAttrs.intent = ASAtomNull;
    pdeImageAttrs.bitsPerComponent = 8;
    pdeImageAttrs.flags = kPDEImageExternal | kPDEImageIsIndexed;
    pdeImageAttrs.decode[0] = fixedZero;
    pdeImageAttrs.decode[1] = fixedOne;
    pdeImageAttrs.decode[2] = fixedZero;
    pdeImageAttrs.decode[3] = fixedOne;
    pdeImageAttrs.decode[4] = fixedZero;
    pdeImageAttrs.decode[5] = fixedOne;
    ASFixedRect theMediaBox;
    PDPageGetMediaBox( AVPageViewGetPage(pageView), &theMediaBox );
    ASFixed theFixedWidth = (theMediaBox.right - theMediaBox.left);
    ASFixed theFixedHeight = (theMediaBox.top - theMediaBox.bottom);
    imageMatrix.a = ASInt16ToFixed(theFixedWidth);
    imageMatrix.d = ASInt16ToFixed(theFixedHeight);
    imageMatrix.b = imageMatrix.c = fixedZero;
    imageMatrix.h = 0;
    imageMatrix.v = 0;
    const Int32 cPaletteColors = 256;
    PDEIndexedColorData theIndexedData;
    theIndexedData.size = sizeof(theIndexedData);
    theIndexedData.baseCs = PDEColorSpaceCreateFromName(ASAtomFromString( "DeviceRGB"));
    theIndexedData.hival = cPaletteColors - 1;
    unsigned char data[3] = {255, 0, 0};
    theIndexedData.lookup = (char *)data;
    theIndexedData.lookupLen = cPaletteColors * 3;
    PDEColorSpaceStruct theColorData;
    theColorData.indexed = &theIndexedData;
    pdeColorSpace = PDEColorSpaceCreate(ASAtomFromString( "Indexed" ), &theColorData );
    pdeImage = PDEImageCreate(&pdeImageAttrs, sizeof(pdeImageAttrs), &imageMatrix,
                                                0, pdeColorSpace, NULL, NULL, NULL, (unsigned char*)buff, theImageByteSize);
    I want die, I had done this for so many days, My GIF doesn't insert into pdf,
    unsigned char data[3] = {255, 0, 0};
    theIndexedData.lookup = (char *)data;  "
    whether the data set wrong?
    I confused what I do next   

  • Converting a binary string into a JPEG image in Crystal Reports 2008

    Hi Gang
    Iu2019m having problems converting a binary string into an image in Crystal Reports 2008
    I have JPEG images stored in ECC.  ECC stores the data in binary format.
    Iu2019m using the ECC function module SKWF_PHIO_CONTENT_ACCESS_GET to retrieve the data.  This function module has an export table, FILE_CONTENT_BINARY, which returns several lines of data.  Each line contains a maximum of 1,024 characters.
    When I drop the T_ FILE_CONTENT_BINARY.LINE field into my Crystal Report detail section, I wind up with a report that displays all the lines in FILE_CONTENT_BINARY table.  (in my case, 19 lines are displayed.)
    I created a formula to collect all the data into a single string.
    whileprintingrecords;
    stringvar data:= data & {SKWF_PHIO_CONTENT_ACCESS_GET.T_FILE_CONTENT_BINARY.LINE}
    I added the formula to the detail section and itu2019s doing a great job collecting the data.
    I then inserted a picture object in the report footer, opened the format editor, navigated to the u201Cpictureu201D tab, and inserted a formula for the u201Cgraphics locationu201D.
    whileprintingrecords;
    stringvar data:=data;
    data
    My clever idea turned out to be a disappointment . . . . my picture object is blank.
    Does anyone have a solution for converting a binary string into a JPEG image?

    Save the JPEG in a format CR supports. Refer to the help file for the file types.

  • XML document convert into String and Insert into Database

    Hello all,
         In the FIle to File Scenario  I want to send the data to the Reciever System in xml Document and convert into String and insert into Database.
      Please can you tell me exact way how to send it.
    Thanks & Regards,
    Raj

    HI,
    As per my understanding your scenario is File to file where you will get output fiel in XML format.
    Now that XMl payload need to be passed as single string in the database via XI.
    You cauld do this but you need to imply some manipulations such as
    With the help of standard API you need to concatenate the  XML tags and create the structre along with the data.
    For e.g. in your outpuf file the XML structre contain data as
    <field1>ABCD</field1>
    Then in mapping
    The source field will be mappeda s concat(<field1>) + value of  Source field "ABCD" + concat(</field1>) to the target field.
    This is the way that you could achive the requirments else there is no direct way avaialble for it.
    thanks
    Swarup

  • How to store an image into database table

    Hi
    Can anyone tell me the way, how to store an image into database table.

    Hello,
    May be this thread will help you in your requirement.
    [FM for uploading Image to SAP;
    Thanks,
    Jayant

  • Urgent : how to put an image into database and how to get it from it?

    hi,
    in the database i made a longblob type for image, and in my java code i have the path of the image (String): "C:\............." and i want to put this image in my data base.
    also i want to know how to get the image after put it in the database.
    please help me, it's so urgent.

    This is a way of getting the image out of the database.
    class yourClass{
    private byte[] buff;
    private ByteArrayOutputStream byteArrayOutputStream;
    public yourClass()
    Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    ResultSet result = statement.executeQuery("your query");
    while ( result.next()){
    try{
    BufferedInputStream bin = new BufferedInputStream(rs.getBinaryStream("imagecolumn"));
    byteArrayOutputStream = new ByteArrayOutputStream();
    int length = bin.available();
    buff = new byte[length];
    while ( bin.read( buff, 0, length ) != -1 ) {
    byteArrayOutputStream.write( buff, 0, length );
    bin.close();
    catch(Exception e){
    The class about is used to take the image out of the database and store it in an object which is then streamed out through a servlet to display on the jsp page.
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    import java.sql.*;
    public class ImageServlet extends HttpServlet {
    public void init() throws ServletException {    }
    public void destroy() {    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    try
    yourClass pro = (yourClass)request.getSession().getAttribute("object");
    while ( iterator.hasNext() ) {
    pro = ( Product ) iterator.next();
    response.setContentType("image/jpg");
    ByteArrayOutputStream byteArrayOutputStream = pro.getImage();
    response.setContentLength( byteArrayOutputStream.size() );
    response.getOutputStream().write( byteArrayOutputStream.toByteArray() );
    response.getOutputStream().flush();
    return;
    catch (Exception e)
    e.printStackTrace();
    throw new ServletException(e);
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    doGet(request, response);
    This is a little messy but if you search the forums you will find out more on it. Search for Images and database.

  • How can I convert a string into an image

    I want to convert a string into an image.
    I want to know required steps for that.

    look at http://forum.java.sun.com/thread.jsp?forum=31&thread=194763
    drawString looks as something you might need

Maybe you are looking for