ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Sietse Brouwer <sbbrouwer@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: error when using externalfigure
Date: Mon, 26 Nov 2012 16:01:51 +0100	[thread overview]
Message-ID: <CAF=dkzxEcWPVay1nyoSgVwSQxtLVXkPfyEvzMFkKTrc2kFmUcA@mail.gmail.com> (raw)
In-Reply-To: <50B36148.9070008@wxs.nl>

This seems to me a case of garbage in, garbage out; I'd say it's the
script's job, rather than ConTeXt's, to ensure the images have the
correct dpi to get a reasonable width in inches. (Brr. I hate inches.
Disgusting, Mars-mission-wrecking way of measuring things.)

Here is some pseudocode. You'd still need a way to get
image.width_in_pixels and image.dpi from the image; I daresay either
`convert` or `exiftool` can do the job. See also this recent mail to
the list by Guy Stalnaker:
http://archive.contextgarden.net/message/20121123.232556.bf205641.en.html

projected_width = image.width_in_pixels / image.dpi
if projected_width > max_width_in_inches then
   required_dpi = image.width_in_pixels / max_width_in_inches
   shell('convert --density %f %s', required_dpi, image_name)
end

Cheers,
Sietse

On Mon, Nov 26, 2012 at 1:32 PM, Hans Hagen <pragma@wxs.nl> wrote:
> On 11/26/2012 11:00 AM, luigi scarso wrote:
>>
>> On Mon, Nov 26, 2012 at 10:50 AM, Hans Hagen <pragma@wxs.nl> wrote:
>>>
>>> On 11/26/2012 10:36 AM, luigi scarso wrote:
>>>>
>>>>
>>>> On Mon, Nov 26, 2012 at 10:20 AM, Pavel Dohnal <pavel.dohnal@twobits.cz>
>>>> wrote:
>>>>>
>>>>>
>>>>> Hello,
>>>>> I have a big context source file which contains pictures from different
>>>>> sources. The problem is, that there are some pictures the context
>>>>> cannot
>>>>> process. It displays an error message and ends. I run the context from
>>>>> another script in batchmode. After finishing, the context creates a PDF
>>>>> file, which contains this problematic picture but the pdf is broken. It
>>>>> does
>>>>> not have numbers in the table of contents and it is not arranged by
>>>>> setup.
>>>>> Here is a minimal example:
>>>>> \starttext
>>>>>
>>>>>
>>>>> \externalfigure[http://cdn-locations-images.tripomatic.com/img-poi1295-5ZTynx-s.jpg][width=26.5mm]
>>>>> \stoptext
>>>>
>>>>
>>>>
>>>>
>>>> when I save the jpg  as eps from gimp
>>>> I see
>>>> width = 6096,00
>>>> height=4064,00
>>>>
>>>> The first value is off for TeX.
>>>
>>>
>>>
>>> if i print the values from the img object i get
>>>
>>> 17344.8pt
>>> 11563.2pt
>>>
>>> so the problem is deep down in the jpg reader ... the image is crippled
>>> in
>>> the sense that it has no valid resolution information
>>>
>>> something for hartmut to check in the img lib
>>
>>
>> Hm, I'm not sure. It's an image that could be correct, but TeX cannot
>> manage it.
>> It has 240x160 pixels and 1ppi, so it's 6,096 meters x 4,06400meters
>> and 6 meters are too much for TeX (which still has its limits around
>> 5meters)
>> It's ok to print poster maybe, but then  TeX  is not the right tool.
>
>
> yes, but the 1,1 resolution prevents us from doing anything useful, i.e. we
> could for instance have something
>
> if xresolution < 72 then xresolution = 72 end
>
> but I'm not sure what the pdf backend will do as then the uses resolution
> for front and backend differ too much
>
> i'll add an overflow check but keep in mind that in that case scaling is
> bases on the limited size
>
>
> -----------------------------------------------------------------
>                                           Hans Hagen | PRAGMA ADE
>               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
>                                              | www.pragma-pod.nl
> -----------------------------------------------------------------
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


  reply	other threads:[~2012-11-26 15:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-26  9:20 Pavel Dohnal
2012-11-26  9:27 ` Hans Hagen
2012-11-26  9:56   ` Pavel Dohnal
2012-11-26  9:36 ` luigi scarso
2012-11-26  9:50   ` Hans Hagen
2012-11-26 10:00     ` luigi scarso
2012-11-26 10:10       ` Martin Schröder
2012-11-26 10:40         ` Pavel Dohnal
2012-11-26 10:50           ` luigi scarso
2012-11-26 12:32       ` Hans Hagen
2012-11-26 15:01         ` Sietse Brouwer [this message]
2012-11-26 19:54     ` Dr. Hartmut Henkel
2012-11-26 20:42       ` Hans Hagen
     [not found] <mailman.384.1353926481.2161.ntg-context@ntg.nl>
2012-11-26 11:21 ` Robert Blackstone

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAF=dkzxEcWPVay1nyoSgVwSQxtLVXkPfyEvzMFkKTrc2kFmUcA@mail.gmail.com' \
    --to=sbbrouwer@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).