Closed bedibik closed 2 years ago
The Scaler mode
selects both the algorithm and the scaling factor (see list of values below). The scaling factor and the input image resolution determine the output image resolution (input width * scale factor = output width
).
https://github.com/bbbbbr/gimp-plugin-pixel-art-scalers/blob/master/src/filter_scalers.h#L43 I've added comments here for readbility in the enum
enum scaler_list {
SCALER_ENUM_FIRST = 0,
SCALER_2X_HQX = SCALER_ENUM_FIRST, // 0
SCALER_2X_XBR, // 1
SCALER_2X_SCALEX, // 2
SCALER_2X_NEAREST, // 3
SCALER_3X_HQX, // 4
SCALER_3X_XBR, // 5
SCALER_3X_SCALEX, // 6
SCALER_3X_NEAREST, // 7
SCALER_4X_HQX, // 8
SCALER_4X_XBR, // 9
SCALER_4X_SCALEX, // 10
SCALER_4X_NEAREST, // 11
SCALER_ENUM_LAST
};
As for the size- I think what you're seeing (and what I saw when I tested) is that the plugin is able to resize the image, but for some reason the drawable (layer) area appears to get clipped in BIMP unlike under normal plugin operation.
So it can create the larger image, but you only get to see the upscaled output for the region which matches the area from the original image (1/4 of the output image size if you're doing 2x, 1/9 of the output image if doing 3x, etc).
This is the code where it performs the output image resize: https://github.com/bbbbbr/gimp-plugin-pixel-art-scalers/blob/master/src/filter_dialog.c#L666
Here is where it gets called in BIMP: https://github.com/alessandrofrancesconi/gimp-plugin-bimp/blob/master/src/bimp-operate.c#L942
It's not clear to me where the problem is. The pixel art plugin works under normal operation, so something must be different in how it gets called under BIMP.
What is interesting is that after BIMP runs it, gimp_drawable_width() and height (new scaled size) no longer match the output of gimp_drawable_mask_intersect() (non-scaled size).
gint width, height, x, y;
gboolean result;
result = gimp_drawable_mask_intersect (gimp_image_get_active_drawable(out->image_id), &x, &y, &width, &height);
g_print("%d, %d %dx%d = %d\n", x, y, width, height, result);
g_print("%dx%d\n", gimp_drawable_width(gimp_image_get_active_drawable(out->image_id)),
gimp_drawable_height(gimp_image_get_active_drawable(out->image_id)));
output for a source 33 x 20 image
0, 0 33x20 = 1
66x40
Actually, I think I found the problem and a solution (in changing BIMP).
In the BIMP source code it seems to set the selection to "All" of the image right before calling my plugin.
int single_drawable = gimp_image_merge_visible_layers(out->image_id, GIMP_CLIP_TO_IMAGE);
gimp_selection_all(out->image_id);
https://github.com/alessandrofrancesconi/gimp-plugin-bimp/blob/master/src/bimp-operate.c#L951
But since it does that, the plugin is going to try and honor the selection area and only operate within it (as is typical for most plugins). And the selection area does not grow to match the resized image (since my plugin resizes the image but doesn't rescale the underlying image since the user may not want that for all layers).
If I change the BIMP source code to select NONE, then the full scaled images show up in the output. It's not clear to me whether the use of gimp_selection_all()
instead of gimp_selection_none
is intentional or not.
int single_drawable = gimp_image_merge_visible_layers(out->image_id, GIMP_CLIP_TO_IMAGE);
gimp_selection_none(out->image_id);
The changes to BIMP for compatibility have been merged, so you should be able to use it with this plugin whenever they release the next build that includes PR # 313 there.
Hi, I'm trying to batch a large number of images with your plugin in BIMP and I'm having some issues. I can't seem to control the resolution or much of anything really. These are the options I see:
The end result of the image also results in 3/4ths of the image being cut out, leaving only the upper left corner:
if you could please advise, I have a very large amount of images to process and I would greatly appreciate the help