merge multiple JPEG file into one file

anyone know how to merge JPEG file into one file?

example :
i want to create software that can merge 5 JPEG file into one file.
this one file can be opened but only with my software.
so in my software i can look this images but at different page
i mean i can see 1.jpg then 2.jpg then 3.jpg

please tell me the solution...

i don't need the program but i need "How to"

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

i dont believe that the jepg format supports multipage - tiff does and you can murge multipil jegs into a tiff.
It sounds like you want to make you own img format that only your software can read. is this correct?

here is the route I would take:

create a random access datafile - this way you keep the original jpeg files intack incase you need them later.

create a type that has the image data and possibly some extra info about the image
output all 3 types to the .xxx file

then you can use a simple vb image control to display the images.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Not sure if this will help,but check out this example:
Not sure if this will help,but check out this example:

Just a quick note of consideration.  To solve this problem you have one issue you have to get around.  That issue is how you are going to convert/revert a .JPG or picture into an array of BYTE.  Once you do this then it is easy enough to write/read the byte array to/from a binary file.

The problem is that there is no easy way to do this in VB other than one that I am not personally satisfied with.  As a result most sample code you see on the web for this type of problem will use this simple approuch.  Basically it goes like this.

Write the JPG to a temporary file.
Read that temporary file into a BYTE array.
Throw the BYTE array into a DB or in your case append it to you combined file.

In the code sample given by vinnyd79 this is basically what is happening; although, in its case it doesn't need the first step since it is asking the user for a path to an existing .JPG file.  That first step is only important for code that needs to manage pictures that do not already exist in files.

Now, there are harder ways to get around all of this using API calls or easy but costly ways of buying a third party image control that will give you access to the Binary image data or long runtime methods of quarying each pixel and generating the BYTE array directly from the picture control; however, if the above method does not bother you then that is probably the quickest/easiest approuch.
what you could do is making a completely binary file, but you need to make it idiot secure or murphies law will haunt you.
what you need is the lengths of the files, eg:

file1.jpg = 1000bytes
file2.jpg = 1500bytes
file3.jpg = 500bytes

file lengths can be obtained with FileLen() function

then you need to open the files you want to merge 1 by 1 while having an output file ready. put in the length of the input file, and then get the data from the first file and put down the other, eg:

Open output file (For Binary)

Write size of the input file1 as a long to the output file
Open input file1 (For Binary)
Copy the contents of input file1 to output file
Close input file1

Write size of the input file2 as a long to the output file
Open input file2 (For Binary)
Copy the contents of input file2 to output file
Close input file2

Write size of the input file3 as a long to the output file
Open input file3 (For Binary)
Copy the contents of input file3 to output file
Close input file3

Close output file

now this is a very primitive way of merging.
to read you simply read the size of a long, and then read the number as many bytes as the long says. so if the long says 1000 then you read 1000 bytes and put into a normal jpg file and load it with LoadPicture()

now to extract files youll have reverse this by reading a long (4 bytes) and then copying as many bytes out of the file as the long indicates, eg:

Open input file (For Binary)

Open output file1 (For Binary)
Read the size indicator (long, 4 bytes)
copy <long> bytes out of the file and into output file1
Close output file1


Close input file

then you can use loadpicture to load the jpg as normally. when its loaded i think you can actually delete the file and have the file only in your picturebox.

I hope this answers your question
/Z out
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.