Re: jpg file to blob in MySQL



Ike wrote:
> I am reading a jpeg file into a byte []:
>
> File flimage = new File("c:\temp.jpg");
> byte[] b = new byte[(int)flimage.length()];
> try{
> InputStream isImage = new FileInputStream(flimage);
> isImage.read(b);
> }catch(Exception e){
> e.printStackTrace();
> return null;
> }
>
> It returns a valid byte[].

Is the actual content of this byte[] the same as the image file? I.e.:
- was the file read fully?
- saving this byte[] back to a FileOutputStream with different name gives a correct image?
- use this byte in your next code (the one to display the image from the blob) and see if it works

Another option would be to convert the initial byte[] (from the inputstream) to a non-binary array (base64 or hexa values) and save it to the blog. Then when reading it back, converting to the original format. But this solution needs processing time and takes more space in the DB.

--
JSC
.



Relevant Pages

  • Re: Color Photo to Grayscale Converter
    ... Are all color to grayscale converter algorithm the same? ... many different levels of qualities to it like scanning or printing? ... A problem with converting by just desaturating to greyscale, then making contrast adjustments, is getting smooth gradations, as greyscale has only 255 levels in an 8 bit image file, so integer rounding can easily cause posterisation / banding. ...
    (rec.photo.digital)
  • Re: Virtual CD-Rom Drive
    ... about the other suggestion you said about reading from another cd-rom,...etc ... in this case can i make an image file from a game cd ...
    (microsoft.public.development.device.drivers)
  • Re: getting histogram data from an image?
    ... I am trying to find a way of reading an image file, ... a 0:255 matrix with the frequency of the pixel value as the element ... like that *snaps fingers*. ...
    (comp.soft-sys.matlab)
  • converting wefax sound file to img, linux
    ... is there software out there for converting a recorded wefax ... that will take a sound file and convert it into an image file, ... recording the audio file at the correct time and for the right ...
    (rec.boats.electronics)
  • Re: converting wefax sound file to img, linux
    ... is there software out there for converting a recorded wefax ... that will take a sound file and convert it into an image file, ... recording the audio file at the correct time and for the right ...
    (rec.boats.electronics)