Cropping image automatically

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
zishanj
Posts: 2
Joined: 2013-01-28T11:17:02-07:00
Authentication code: 6789

Cropping image automatically

Post 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?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Cropping image automatically

Post 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.
snibgo's IM pages: im.snibgo.com
zishanj
Posts: 2
Joined: 2013-01-28T11:17:02-07:00
Authentication code: 6789

Re: Cropping image automatically

Post 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......
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Cropping image automatically

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply