How To Cut & Merge Text & Img Files With Php ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
UniqueIdeaMan
Forum Contributor
Posts: 197
Joined: Wed Jan 18, 2017 3:43 pm

How To Cut & Merge Text & Img Files With Php ?

Post by UniqueIdeaMan »

Happy Holiday Php Guys! :)

You know, few yrs back I've fiddled with file cutting software where I cut a file into lots of smaller files. I've also merged lots of files into one.
Now, I did all this with a desktop software (.exe).
Now, I want to do it with php.
Therefore, in order to cut & shorten and merge and enlarge text files, which functions should I look into ?
Same question goes for img files.
First, I want to cut an img file into many smaller files. For example, look at this img here:
Logo Design Tool. Free and Online.

The img shows text: Happy New Year.
That phrase is displayed using a certain font.
Now, I want to have each letter/char on it's own. That means, I need to cut the img file into many smaller files so each file only contain one letter/char. Eg.
h.jpeg
a.jpeg
p.gpeg
py.jpeg
y.jpeg

and so on.
So, how do I break an img file into lots of smaller files ? Which function to use to do that ?
I can break the file in 3 ways:

1. Cut the file into many smaller files by inserting a number. Like break the big file into 10 smaller files.

2. Cut the file into many smaller files by inserting a percentage. Like break the big file into 20% smaller files. (This would break into 5 files only).

3. Cut the file into many smaller files by inserting a delimiter. The delimiter can be a colour. In this example:
Logo Design Tool. Free and Online.
If I insert black as the delimiter then each file would be separated using black as the separator. That means, each char would be separated by the black colour (background colour). Result ? I'd get each file containing one char/letter.
You do understand what I'm trying to do, right ? From this img in our example, I'm trying to extract all the chars and save each char on a separate file on it's own. In this case, 12 files would be created for 12 chars.

Now, I need to do all this with php. And so, how do I do it ? Which functions to use ? Have you experimented with this type of thing ?


Erm: I always come-up with good idea projects for a beginner for my learning purpose. Is not that so ? Always adventurous. Yes, I am a different type of student. Unorthodox. A unique student. A unique way of learning student. And, you're going to be the unique type of helper. :)
Where's the fun when every student or teacher does things the orthodox way ? Let's make a change. :cool:
Post Reply