Page 1 of 1
Cropping image automatically
Posted: 2013-01-28T11:24:19-07:00
by zishanj
Hello,
I ran into an issue where I want to:
- first convert one paragraph of about 10 sentences into PNG with formatted in justify
- then I have to crop that image after end of every sentence. I mean I have to crop it to get separate image of every sentence.
Is there any idea to accomplish both this task?
Re: Cropping image automatically
Posted: 2013-01-28T14:20:35-07:00
by snibgo
Step 1 is easy but step 2 is hard. This sounds like one of those daft exercises professors invent to keep their students quiet for a week or two. Figuring out the start and end of sentences is much easier when they are still text, than when they have been converted to raster images. Even when they are text, it isn't trivial. "Is this one sentence or two?" he asked.
Re: Cropping image automatically
Posted: 2013-01-28T14:40:26-07:00
by zishanj
I am actually trying to implement a workaround where non-english languages doesn't display correctly on mobile devices. The workaround I thought was to transform into image and get track of the sentence positions in it. Transforming to image is easy but to track it......
Re: Cropping image automatically
Posted: 2013-01-28T17:07:45-07:00
by anthony
To track, I would separate into sentences first. Then generate a image of one sentence, then another of the first the sentences.
The difference in images should (SHOULD) be the sentence boundaries.
The next bit is not specific to IM....
The caveat here is justification. If you use 'justify' option with some text to image processors may rearrange what words go on what line to better reduce spacing in lines when some long words are present. TeX book processing package does this). Also if there is little space left on the last line of justified text, some packages may 'justify' the last line, when normally (last line is shorter) it doesn't. I have seen web browsers do this.
As such caution is needed in general, with a good set of test cases.