Um parâmetro contendo números reais não aceitos no Linux

1

Em primeiro lugar, este comando funciona bem no prompt de comando do Windows.

kdu_expand -i /home/tmp/1.jp2 -o /home/tmp/1.tif -region {0.1,0.1},{0.1,0.1}

No Linux, recebo o seguinte erro:

The '-region' argument requires a set of coordinates of the form, "{<top>,<left>},{<height>,<width>}". All quantities must be real numbers in the range 0 to 1.

Se eu remover o parâmetro -region e executar assim:

kdu_expand -i /home/tmp/1.jp2 -o /home/tmp/1.tif

funciona no Linux também.

Aqui está a parte do código que analisa o parâmetro:

    static void
  set_region_of_interest(kdu_args &args, kdu_dims &region, siz_params *siz,
                         double &width_fraction, double &height_fraction)
  /* Parses the '-region' argument to see if a reduced region of interest
     is required.  Returns the region of interest, expressed on the
     original codestream canvas (no geometric transformations) along with
     the fraction of the full image width and height which are represented
     by this region. */
{
  width_fraction = height_fraction = 1.0;
  if (!(siz->get(Sorigin,0,0,region.pos.y) &&
        siz->get(Sorigin,0,1,region.pos.x) &&
        siz->get(Ssize,0,0,region.size.y) &&
        siz->get(Ssize,0,1,region.size.x)))
    assert(0);
  region.size.y -= region.pos.y;
  region.size.x -= region.pos.x;
  if (args.find("-region") == NULL)
    return;
  char *string = args.advance();
  if (string != NULL)
    {
      double top, left, height, width;

      if (sscanf(string,"{%lf,%lf},{%lf,%lf}",&top,&left,&height,&width) != 4)
        string = NULL;
      else if ((top < 0.0) || (left < 0.0) || (height < 0.0) || (width < 0.0))
        string = NULL;
      else
        {
          region.pos.y += (int) floor(region.size.y * top);
          region.pos.x += (int) floor(region.size.x * left);
          region.size.y = (int) ceil(region.size.y * height);
          region.size.x = (int) ceil(region.size.x * width);
          width_fraction = width;
          height_fraction = height;
        }
    }
  if (string == NULL)
    { kdu_error e; e << "The '-region' argument requires a set of coordinates "
      "of the form, \"{<top>,<left>},{<height>,<width>}\". All quantities "
      "must be real numbers in the range 0 to 1."; }
  args.advance();
}
    
por Nevermore 15.05.2018 / 11:00

1 resposta

3

O parâmetro {0.1,0.1},{0.1,0.1} está sujeito à expansão de chaves no shell do Linux. Você pode verificar com echo :

$ echo {0.1,0.1},{0.1,0.1}
0.1,0.1 0.1,0.1 0.1,0.1 0.1,0.1

$ echo A{0.1,0.1},{0.1,0.1}B
A0.1,0.1B A0.1,0.1B A0.1,0.1B A0.1,0.1B

Para evitar esse comportamento, coloque o parâmetro entre aspas simples ( '...' ).

kdu_expand -i /home/tmp/1.jp2 -o /home/tmp/1.tif -region '{0.1,0.1},{0.1,0.1}'
    
por Melebius 15.05.2018 / 11:28