From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ig0-f181.google.com ([209.85.213.181]) by ur; Mon Oct 26 18:51:48 EDT 2015 Received: by igbkq10 with SMTP id kq10so83730916igb.0 for <9front@9front.org>; Mon, 26 Oct 2015 15:51:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=mTSsgNc/mKgvrp8UDq8+KhYU3bcfZAqmz1gsYopzGp0=; b=lQfnnMy1fNS5Rbx40w7RxKzyHBh8SDCJOE23APWSigG8GDE2kmjhXkbVmgGjbr8MLq wawla/5UPWYCcRDsb4U1rwGqb3WUCV6DdLbKZ3okDtPglt7jah3o801XTAty9DYs7WBf QNeoHK+vcZV1JZGiknkQjT58jJAF4IeSr1OjJ//H3ZX/GDhHWlu4L63L5UxxoUwFweXL Caay0uUjvA7dtXLjRE7op2tdSVOb1tvgf81sCOKr+UHMH8dajRG66G/5pKVpqsWy7bcP tTjm7BKD25meAW3FSU0erbglh0T/nwWsmeBrm/AmDY/WIVG1Vh+p0a+GG7IEk5VIcxSo 6/IQ== MIME-Version: 1.0 X-Received: by 10.50.111.170 with SMTP id ij10mr8889405igb.88.1445899906425; Mon, 26 Oct 2015 15:51:46 -0700 (PDT) Received: by 10.50.136.65 with HTTP; Mon, 26 Oct 2015 15:51:46 -0700 (PDT) Date: Mon, 26 Oct 2015 22:51:46 +0000 Message-ID: List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: encrypted webscale hypervisor HTML engine hypervisor Subject: crop(1) -c negative coordinates From: istvan bak To: 9front@9front.org Content-Type: text/plain; charset=UTF-8 The -c flag in crop(1) works incorrectly for images that have a nonzero upper left corner X coordinate. It crops the left and right side of the image relative to [0, width[, instead of [r.min.x, r.max.x[ . So, images with r.min.x < 0 have their left side eaten away and their right side kept with the unwanted border. One can make such images with paint(1). Rectangle coords of images can be viewed with tweak(1). I presume such rectangles are normal and that images don't usually need to be normalized (please confirm?). A way to trigger the bug: Add wide enough pink border (this works as expected): crop -i -100 -b 255 150 150 image | page Remove maximum amount of pink border: crop -i -100 -b 255 150 150 image | crop -c 255 150 150 | page Lament the fact that pink border remains on at least one side. Fix below; apologies if gmail hard wraps long lines. /sys/src/cmd/crop.c:34,40 - crop.c:34,40 crop(Memimage *m, ulong c) { Memimage *n; - int x, y, bpl, wpl; + int i, x, y, bpl, wpl; int left, right, top, bottom; ulong *buf; /sys/src/cmd/crop.c:61,68 - crop.c:61,69 x = unloadmemimage(m, Rect(m->r.min.x, y, m->r.max.x, y+1), (uchar*)buf, bpl); if(x != bpl) sysfatal("unloadmemimage"); - for(x=0; xr.min.x + i; if(x < left) left = x; if(x > right)