Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to convert JPEG to binary using Java & save into database

Reply
Thread Tools

How to convert JPEG to binary using Java & save into database

 
 
himaloy
Guest
Posts: n/a
 
      10-04-2006
Hi,

i need to know how can i convert a JPEG grey scale image into binary
file using Java and save that file into a database for example MySql...

is it hard to do?

Thnks..

 
Reply With Quote
 
 
 
 
Baby Lion
Guest
Posts: n/a
 
      10-04-2006
write it to an array of byte
then save it to blob of DB
you can search blob in jdk api document
himaloy 写道:

> Hi,
>
> i need to know how can i convert a JPEG grey scale image into binary
> file using Java and save that file into a database for example MySql...
>
> is it hard to do?
>
> Thnks..


 
Reply With Quote
 
 
 
 
Manish Pandit
Guest
Posts: n/a
 
      10-04-2006
Hi,

I would recommend storing the files on the file system, and store the
pointers to the files in the database instead of a blob (unless you're
storing thumbnails or files relatively small in size). You can store
something like server/folder/filename in mySQL for every file, which
should give your app enough info to pull the file when need be.

-cheers,
Manish

 
Reply With Quote
 
Simon Brooke
Guest
Posts: n/a
 
      10-04-2006
in message <(E-Mail Removed). com>, Manish
Pandit ('(E-Mail Removed)') wrote:

> I would recommend storing the files on the file system, and store the
> pointers to the files in the database instead of a blob (unless you're
> storing thumbnails or files relatively small in size). You can store
> something like server/folder/filename in mySQL for every file, which
> should give your app enough info to pull the file when need be.


H'mmmm... this is what I currently do. It's simple and 90% of the time it
works. But if the file in the file system gets moved or deleted, it
breaks. Actually shoving the data into the database has the advantage that
the database looks after referential integrity (i.e., in this case, the
image doesn't get deleted unless the record gets dropped).

--
http://www.velocityreviews.com/forums/(E-Mail Removed) (Simon Brooke) http://www.jasmine.org.uk/~simon/

IMHO, there aren't enough committed Christians, but that's care
in the community for you. -- Ben Evans

 
Reply With Quote
 
Manish Pandit
Guest
Posts: n/a
 
      10-04-2006
Simon Brooke wrote:
> But if the file in the file system gets moved or deleted, it
> breaks. Actually shoving the data into the database has the advantage that
> the database looks after referential integrity (i.e., in this case, the
> image doesn't get deleted unless the record gets dropped).
>


In that case the file system should be controlled - and people/process
should be well aware of the consequences of moving the files around. If
you do want to take the blob route, do ensure to load test the system,
as I am quite sure blob selects will slow down your system
considerably, based on the image size, access frequency and access
mechanism (filtered vs. lookup..).

-cheers,
Manish

 
Reply With Quote
 
steve
Guest
Posts: n/a
 
      10-04-2006
On Thu, 5 Oct 2006 01:46:33 +0800, Baby Lion wrote
(in article <(E-Mail Removed). com>):

> write it to an array of byte
> then save it to blob of DB
> you can search blob in jdk api document
> himaloy 写道:
>
>> Hi,
>>
>> i need to know how can i convert a JPEG grey scale image into binary
>> file using Java and save that file into a database for example MySql...
>>
>> is it hard to do?
>>
>> Thnks..

>


lame idea number 1.

 
Reply With Quote
 
steve
Guest
Posts: n/a
 
      10-04-2006
On Thu, 5 Oct 2006 02:29:54 +0800, Manish Pandit wrote
(in article <(E-Mail Removed). com>):

> Hi,
>
> I would recommend storing the files on the file system, and store the
> pointers to the files in the database instead of a blob (unless you're
> storing thumbnails or files relatively small in size). You can store
> something like server/folder/filename in mySQL for every file, which
> should give your app enough info to pull the file when need be.
>
> -cheers,
> Manish
>


lame idea number 2

 
Reply With Quote
 
steve
Guest
Posts: n/a
 
      10-04-2006
On Thu, 5 Oct 2006 04:24:38 +0800, Simon Brooke wrote
(in article <(E-Mail Removed)>):

> in message <(E-Mail Removed). com>, Manish
> Pandit ('(E-Mail Removed)') wrote:
>
>> I would recommend storing the files on the file system, and store the
>> pointers to the files in the database instead of a blob (unless you're
>> storing thumbnails or files relatively small in size). You can store
>> something like server/folder/filename in mySQL for every file, which
>> should give your app enough info to pull the file when need be.

>
> H'mmmm... this is what I currently do. It's simple and 90% of the time it
> works. But if the file in the file system gets moved or deleted, it
> breaks. Actually shoving the data into the database has the advantage that
> the database looks after referential integrity (i.e., in this case, the
> image doesn't get deleted unless the record gets dropped).
>
>


finally some sense.

 
Reply With Quote
 
steve
Guest
Posts: n/a
 
      10-04-2006
On Thu, 5 Oct 2006 01:21:48 +0800, himaloy wrote
(in article <(E-Mail Removed). com>):

> Hi,
>
> i need to know how can i convert a JPEG grey scale image into binary
> file using Java and save that file into a database for example MySql...
>
> is it hard to do?
>
> Thnks..
>


just convert to a grey scale, then stream it out to a blob.

if possible leave it in colour, unless you are absolutely sure you will never
need the original image again.

You can always pre-process between the database & the user.

What I actually do is store the images & a thumb nail, in the record.
(pre-process a thumb nail , make it perhaps no more than 5-10% of the
original image)
then for the user pull the thumbnails over to the user & if the user selects
the picture THEN bring over the full image.

Steve




 
Reply With Quote
 
Matt Humphrey
Guest
Posts: n/a
 
      10-05-2006

"steve" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Thu, 5 Oct 2006 01:21:48 +0800, himaloy wrote
> (in article <(E-Mail Removed). com>):
>
>> Hi,
>>
>> i need to know how can i convert a JPEG grey scale image into binary
>> file using Java and save that file into a database for example MySql...
>>
>> is it hard to do?
>>
>> Thnks..
>>

>
> just convert to a grey scale, then stream it out to a blob.


The OP appears to already have a gray scale image and wants to know how save
it to a database.

Your prior message called writing the image to a blob a lame idea without
explaining, which does not help the OP or any other readers also looking for
information. I'd like to hear why you think streaming is now so much better
than writing the byte array directly.

Matt Humphrey (E-Mail Removed) http://www.iviz.com/


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to convert JPEG image into a binary data? Lucas Cowald ASP .Net Building Controls 1 10-19-2003 05:25 AM
How to convert JPEG image into a binary data? Lucas Cowald ASP .Net 2 10-15-2003 05:46 PM
How to convert JPEG image into a binary data? Lucas Cowald ASP .Net Mobile 0 10-15-2003 08:52 AM
How to convert JPEG image into a binary data? Lucas Cowald ASP .Net Datagrid Control 0 10-15-2003 08:51 AM



Advertisments