If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back  dBforums > PC based Database Applications > Corel Paradox > BLOB image extraction

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-13-06, 11:07
campc123 campc123 is offline
Registered User
 
Join Date: Feb 2006
Posts: 10
Question BLOB image extraction

Hi all,
I have a problem in which I've read a lot about but have not been able to come up with a sufficient solution for. I am not very experienced with PARADOX or ObjectPal so this has been a toughy. Any insight on this would be extremely appreciated.

Here is the problem:
I am performing a data conversion on a Paradox database to be imported into SQL Server 2000. I have not had any problems using SQL Server's DTS package for the most part but unfortunately, BLOB fields do not come over.

I have a table called "Image.DB" that has two blob fields. GraphicPhoto (of data type BLOB Graphic) and BinaryPhoto (of datatype BLOB Binary). The Graphic Photo column seems to have nothing stored in it (When I go to BLOB options and check off Complete Display - nothing appears). I have written the following ObjectPal code to extract binary from the BinaryPhoto field into a a picture format (such as .jpg, .gif, .bmp, etc.):

Code:
var
tc   tcursor
bn   binary
cnt  number
endvar

cnt = 0
tc.open(":SIDTables:Image.db")  ; Open the source DB table
scan tc :
  cnt = cnt + 1  
  bn=tc."BinaryPhoto" ; field containing graphic
  bn.writetofile(":ExtractedImages:" + String(cnt) + "img.bmp")  ; write to this 
   ; directory as a .bmp file.  
endscan
tc.close()
This is in fact extracting "something". But I can't figure out what format to put it in - in order to show the actual image.
As I stated before I am not experienced with ObjectPal or PARADOX so I might be missing some important features that I can be using.

Thank you in advance!

Chris
Reply With Quote
  #2 (permalink)  
Old 02-21-06, 15:31
Jonathanwri73 Jonathanwri73 is offline
Registered User
 
Join Date: Feb 2006
Location: Hertfordshire, UK
Posts: 24
Hi, I haven't checked this for sure but if you know the BLOB values are images instead reading into a Binary datatype have you tried reading into a Graphic data type.

So as an example:
Code:
var
  grImage  Graphic
  tcHandle  TCursor
  liCount   LongInt
endVar

if tcHandle.open(":SIDTables:Image") then
   liCount = 1
  
   scan tcHandle :
     grImage = tcHandle.BinaryPhoto
     grImage.writeToFile(":ExtractedImages:" + String(liCount) + "img.bmp")
   endScan
   tcHandle.close()

endIf
I think you may have more success this way.

Regards
Jonathan
Reply With Quote
  #3 (permalink)  
Old 02-21-06, 15:40
campc123 campc123 is offline
Registered User
 
Join Date: Feb 2006
Posts: 10
I would do that but the person who designed this source database originally stored the data in the column as data type BLOB binary. so I'll get an error in my script if I try to assign it as a graphic. Do you think I would lose / or get corrupt data from manually changing the data type to graphic and then trying to execute the script?
Reply With Quote
  #4 (permalink)  
Old 02-21-06, 17:48
Jonathanwri73 Jonathanwri73 is offline
Registered User
 
Join Date: Feb 2006
Location: Hertfordshire, UK
Posts: 24
Sorry, just checked this you will get an error if you try to extract a Binary into a Graphic variable.

However when using a Paradox table and using the data-type Binary, I was able to extract images from the table out to an image file using the following ObjectPAL:

Code:
var
  binHandle  	Binary
  tcImage  	TCursor
endVar

tcImage.open(":usmsvr:imagetest")
scan tcImage :
  binHandle = tcImage.image_binary
  binHandle.writeToFile(":usmsvr:IMAGE_" + tcImage.image_name + ".bmp")
endScan
The alias :usmsvr: is simply my own alias and I created a table called imagetest with 2 fields inside it which were defined as follows:

image_name - Alpha - 30
image_binary - Binary

So am unclear whether there really is anything in these fields on your DB or not.
Reply With Quote
  #5 (permalink)  
Old 02-22-06, 09:33
campc123 campc123 is offline
Registered User
 
Join Date: Feb 2006
Posts: 10
Jon -
I appreciate your comments. I noticed that the ObjectPal you used is very similar to the code i posted. So it's interesting to hear that you were able to get successful results.

I know that something is being extracted because when I run my script i get images with some sort of content - when I open the img with notepad I can see the ASCII. Unfortunately, the images aren't viewable - they all appear to be corrupt.

My first reaction is - yeah the data in the table is corrupt. But I am working with an application that was not written by me. Which puts me in a tough position. I have access to the application and the database tables - but I do not have access to the man who created it (nor do I have access to the forms and their corresponding code - they are password protected). So for all I know he could have been doing something within his code that I can't see. Somehow he is able to make the images viewable tho... I have the app open right now and am looking through the pictures.

maybe if I write some kind of script that converts ascii to hex data? I don't know. Once again though... thanks for batting some ideas around with me.

Chris
Reply With Quote
  #6 (permalink)  
Old 02-22-06, 15:57
Jonathanwri73 Jonathanwri73 is offline
Registered User
 
Join Date: Feb 2006
Location: Hertfordshire, UK
Posts: 24
Hi,

When you say you do not have access to the forms or code because they are password protected.

How are these password protected?
What are the file extensions for the files?

I have never come across Paradox password protecting source files unless the source is stored in say a zip file. In which case there tend to be password recovery/crackers for zip files on the internet.

When you have the app open to look at the pictures, are these all embedded within a form or does it open up another application and if so which application is it starting?

May just give a hint as to what the files really are stored in/as.

Regards
Jon
Reply With Quote
  #7 (permalink)  
Old 02-22-06, 16:27
campc123 campc123 is offline
Registered User
 
Join Date: Feb 2006
Posts: 10
Okay concerning the first part... I'm an idiot - there were certain things that were password protected but they had nothing to do with the application (or so they tell me) - but rather when I try to open the forms and their corresponding code in Paradox it won't let me because it was developed in a previous version of Paradox. Unfortunately when I tried to find out what version was used - no one could tell me. And I don't even know if I have access to an earlier version if I wanted it. This could be trouble.

A seperate application is not opened when displaying these pictures. They are simply embedded in the form.

-Chris
Reply With Quote
  #8 (permalink)  
Old 02-22-06, 16:45
campc123 campc123 is offline
Registered User
 
Join Date: Feb 2006
Posts: 10
the ASCII from each image starts like this...
"LEAD "
does this mean anything in particular? Would this be corrupting the image at all? I'm not quite sure what that is...

like ... "LEAD ;  wZŀӀ" "
Reply With Quote
  #9 (permalink)  
Old 02-22-06, 16:48
campc123 campc123 is offline
Registered User
 
Join Date: Feb 2006
Posts: 10
also.........
when this script runs would it also be pulling from the .MB binary reference file - which is the image reference for the binary that is not sitting in the .DB table? Is it possible to even view .MB's?

just curious if you had any insight on that
Reply With Quote
  #10 (permalink)  
Old 02-22-06, 17:22
Jonathanwri73 Jonathanwri73 is offline
Registered User
 
Join Date: Feb 2006
Location: Hertfordshire, UK
Posts: 24
Hi Chris,

A few questions on the posts you've placed...

What extension do the source files have?

What version of Paradox are you presently using?

How old is the software you are using, it may help narrow down the Paradox version these were developed using.

Do you know or can you have any software from LEAD Technologies installed on the PC?

If not, please search and see if you can find the file LFC.EXE on the PC.

LEAD do have some command line image conversion/compression techniques for JPG files, which it may well be using to extract the binary then convert/decompress to JPG before reading the file into the Graphic object on the form.

As for the .MB yes it will be getting stored in this file but you cannot view the file on it's own it will need to be Paradox or perhaps Delphi.
Reply With Quote
  #11 (permalink)  
Old 02-23-06, 09:51
campc123 campc123 is offline
Registered User
 
Join Date: Feb 2006
Posts: 10
Jon-

A few questions on the posts you've placed...

> What extension do the source files have?
The extension for the images? I'm not sure - I think our client were putting .jpg files into the system... if that's not what you meant... the tables are .DB's - the forms are .fdl's

> What version of Paradox are you presently using?
I'm currently using Paradox v 11

>How old is the software you are using, it may help narrow down the Paradox version these were developed using.
in the about box it says copyright 1993-2004 so i'm guessing 1993?

>Do you know or can you have any software from LEAD Technologies installed on the PC?
I do not have any LEAD Technologies installed - google desktop and the microsoft search tool did not pick up any "LFC.EXE" file... If I downloaded this would it help maybe? Where could I get this?
Reply With Quote
  #12 (permalink)  
Old 02-23-06, 16:43
Jonathanwri73 Jonathanwri73 is offline
Registered User
 
Join Date: Feb 2006
Location: Hertfordshire, UK
Posts: 24
Firstly if you have .fdl's then these are not source, they are compiled so you will not be able to view the source of these.

If the software being used is Paradox 11 then I believe the software would have been updated in 2004.

You will be able to get LFC from www.leadtools.com, although I'm not sure it will be what you have. Was purely a hunch based on the first few characters in the image file.

Alternatively, I'm happy if you want to send me a private mail and arrange to send all the files used by the table to me. I'll happily have a go at seeing if I can get the data out for you.

Regards
Jonathan
Reply With Quote
  #13 (permalink)  
Old 02-23-06, 17:27
campc123 campc123 is offline
Registered User
 
Join Date: Feb 2006
Posts: 10
Whoa!

That LEAD Technologies thing works. When I ran the command line utility against the extracted images it ran a slide show of the pictures and displayed them perfectly. That is crazy stuff~!

I'm getting close now... Now I have to figure out how to get this stuff into SQL Server... Is there a way for it to dump the compressed images to individual files rather then looking at it through a slide show?

You truly put me on the right track, thanks so much.
Reply With Quote
  #14 (permalink)  
Old 02-23-06, 17:56
campc123 campc123 is offline
Registered User
 
Join Date: Feb 2006
Posts: 10
ahhh never mind i was able to make a destination directory to output them to!
Reply With Quote
  #15 (permalink)  
Old 02-23-06, 17:59
Jonathanwri73 Jonathanwri73 is offline
Registered User
 
Join Date: Feb 2006
Location: Hertfordshire, UK
Posts: 24
Try downloading the LEAD Command Line Image File Converter at the following URL:

http://www.leadtools.com/utilities/c...er/default.htm

I personally haven't tried it myself, but I believe you will find the following should take it out of the LEAD compressed format into a standard JPED

LFC <Full directory + File ... i.e. C:\image.jpg> /F6 <Target directory + file ... i.e. C:\output\image.jpg>

This should work manually for one and if this gets the file out for you, then you could could amend my example the ObjectPAL script to do this conversion for you something like the following:

Code:
var
  grImage  Graphic
  tcHandle  TCursor
  liCount   LongInt
  sFile1,
  sFile2    String
endVar

if tcHandle.open(":SIDTables:Image") then
   liCount = 1
  
   scan tcHandle :
     grImage = tcHandle.BinaryPhoto
     sFile1 = getAliasPath(":ExtractedImages:") + String(liCount) + "img_orig.jpg"
     sFile2 = getAliasPath(":ExtractedImages:") + String(liCount) + "img.jpg"
     grImage.writeToFile(":ExtractedImages:" + String(liCount) + "img.bmp")
     execute("LFC.EXE " + sFile1 + " /F6 " + sFile2, No, ExeHidden)
   endScan
   tcHandle.close()
endIf
-Jonathan
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On