Giter VIP home page Giter VIP logo

Comments (8)

jcupitt avatar jcupitt commented on June 13, 2024 1

Hi @knoppmyth,

Oh dear, that sounds bad. I'll investigate later this week.

from libvips.

jcupitt avatar jcupitt commented on June 13, 2024 1

I downloaded the tarball, thanks.

I was able to reproduce this in ubuntu 23.10 with libvips master and this prog:

#!/usr/bin/env python3

import sys
import pyvips

input_directory = sys.argv[1]
output_file = sys.argv[2]
tiles_across = int(sys.argv[3])
tiles_down = int(sys.argv[4])

print(f"loading {tiles_across * tiles_down} tiles ...")
tiles = [pyvips.Image.new_from_file(f"{input_directory}/{x}_{y}.jpg",
                                    access="sequential")
         for y in range(tiles_down)
         for x in range(tiles_across)]

joined = pyvips.Image.arrayjoin(tiles, across=tiles_across)

print("saving ...")
joined.write_to_file(output_file)

It works if I run it like this:

john@banana ~/x/tmp/images/70946.svs/tiles/orig/orig_files $ ~/try/arrayjoin2.py 0 ~/x.tif[compression=jpeg,tile] 366 176
loading 64416 tiles ...
saving ...
john@banana ~/x/tmp/images/70946.svs/tiles/orig/orig_files $

But fails if I run:

john@banana ~/x/tmp/images/70946.svs/tiles/orig/orig_files $ ~/try/arrayjoin2.py 0 ~/x.tif[compression=jpeg,tile] 366 177
loading 64782 tiles ...
(process:181986): GLib-ERROR **: 15:30:25.997: ../../../glib/gmem.c:136: failed to allocate 7044 bytes
Trace/breakpoint trap (core dumped)
john@banana ~/x/tmp/images/70946.svs/tiles/orig/orig_files $

That's suspiciously close to 2^16. I wonder if it's overflowing 16 bits for a file descriptor somewhere?

from libvips.

knoppmyth avatar knoppmyth commented on June 13, 2024

Thanks @jcupitt

from libvips.

jcupitt avatar jcupitt commented on June 13, 2024

I tried in C and it also fails, so it's not python:

/* compile with:
 *
 * gcc -g -Wall try345.c `pkg-config vips --cflags --libs`
 */

#include <vips/vips.h>

int
main(int argc, char **argv)
{
    if (VIPS_INIT(argv[0]))
        vips_error_exit(NULL);

    if (argc != 5)
        vips_error_exit("usage: %s base-dir outfile tiles-across tiles-down",
            argv[0]);

    VipsObject *context = VIPS_OBJECT(vips_image_new());
    int tiles_across = atoi(argv[3]);
    int tiles_down = atoi(argv[4]);
    int n_tiles = tiles_across * tiles_down;
    VipsImage **tiles = (VipsImage **)
        vips_object_local_array(context, n_tiles);

    printf("loading %d tiles ...\n", n_tiles);
    for (int y = 0; y < tiles_down; y++)
        for (int x = 0; x < tiles_across; x++) {
            int i = x + y * tiles_across;

            char filename[256];

            snprintf(filename, 256, "%s/%d_%d.jpg", argv[1], x, y);
            if (!(tiles[i] = vips_image_new_from_file(filename,
                            "access", VIPS_ACCESS_SEQUENTIAL,
                            NULL)))
                    vips_error_exit(NULL);
        }

    printf("assembling ...\n");
    VipsImage *image;
    if (vips_arrayjoin(tiles, &image, n_tiles, "across", tiles_across, NULL))
        vips_error_exit(NULL);

    printf("saving ...\n");
    if (vips_image_write_to_file(image, argv[2], NULL))
        vips_error_exit(NULL);

    return 0;
}

I see:

john@banana ~/x/tmp/images/70946.svs/tiles/orig/orig_files $ ~/try/a.out 0 ~/x.tif[compression=jpeg,tile] 366 175
loading 64050 tiles ...
assembling ...
saving ...
john@banana ~/x/tmp/images/70946.svs/tiles/orig/orig_files $

But 176 fails.

from libvips.

jcupitt avatar jcupitt commented on June 13, 2024

It could be a stack overflow, I guess, I'll check.

from libvips.

knoppmyth avatar knoppmyth commented on June 13, 2024

@jcupitt Thanks for taking a deeper look.

from libvips.

jaume-pinyol avatar jaume-pinyol commented on June 13, 2024

Hi! @jcupitt I'm having the same issue with 8.15.2, what is the status? I was going to see if I can spot the issue but given this issue is some months old maybe someone is already working on it.

from libvips.

jcupitt avatar jcupitt commented on June 13, 2024

Sorry, I've been distracted on other projects. Please have a go if you have time!

from libvips.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.