Close an image with Gimp Script-Fu - gimp

Stoopid question time. How do you close an image in GIMP with Script-Fu?
Sort of the Pythonic version of this: (ignore changes and close)
// close the image WITHOUT saving
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
There's nothing in the Python Procedure Browser for "close"

(You title & tag "script-fu", which is Scheme/Lisp, but then mention Python..., so going for Python...)
The theory is that a script shouldn't interfere with the UI, so you can't close an image at random.
If your script loads an image, the image can be shown to the user using a display=gimp.Display(image) (this is a gimp.Display object). You can also add a display to an already loaded image the same way. Since you created the display, you know it, you own it and so you can close it with gimp.delete(display). When the last display of an image is closed, the image is quitted.
If you don't create the display, you can take advantage of the fact that the display IDs are created in sequence and that this sequence sort of matches the image ids so unless many images have been loaded without a display or many images have go many displays, the display ID and the image ID are close to each other.
And given an integer ID, you can recover the display using the "secret" gimp._id2display(id), so if there is a single image loaded, you can find its Display with something like
for displayID in range(1,image.ID+50):
display=gimp._id2display(displayID)
if isinstance(display,gimp.Display):
break
if not display:
raise Exception('Display not found')
gimp.delete(display)
But this will misbehave if there is more than one image loaded, so beware.

Related

How do I record and display the output of an EXE Window into another EXE Window

So for example let's say I have a game running, I want to grab the image output of the game and display it onto another window I have, so I would have two identical looking windows, one with the game itself, and one with the output of it. I want this to be done with LUA.
You can try wxwidgets library (with wxlua wrapper), as it provides access to the screen device context to read its pixels. See for example this takeScreenshot function that saves a section of the display into a PNG file.

How to get live output while processing images in ImageJ?

All what I am describing here takes place in ImageJ 32-bit version(Java 1.6.0_20).The Plugin I am using to get the capture stream from the camera is Civil Capture.
I made it work that i get image slices in a stack from a live video capture stream, with a camera. Afterwords I process them, lets just say i feed the values of one horizontal line of pixels of one image in an array and than plot this line with the methods from Plot and Plot Window.
So now my Problem:
When I run my plugin it first captures the picture than it gets processed. Now a Window is beeing opend for the Image stack and one for the Plot.
For the next incoming image it will also be processed and the Plot is beeing updated. But only at the end, when as many images, as I want to, were processed, the Plot and the images will actually be displayed. While the processing is happening, both Windows are white and dont show anything.
Is it possible to make ImageJ display the plot and the images after the processing part? and how?
I have found the Dynamik Profiler but I didnt get it to work the way I wanted it to. Especally since you have to input a image and not an array.
This is my first question so dont be too hard on me if i missed to give you information.
You should be able to use ImagePlus#updateAndDraw() to update the image display.
For the Plot class, use:
Plot#show()
to display it for the first time, and:
Plot#updateImage()
to update the plot window.
Solution:
So the problem was that the entier program took place in one thread. So to fix it, the ploting had to be done in a seperat thread.

Delphi Fortes Report angleLabel on top, across a report

I am making the invoice part of an application, and at this moment I am done with the invoice generation (adding products and stuff).
The next step is to have a report displaying the invoice data, ready to print.
That works too. I used Fortes Reports because it is free, easy to work with, and has a free PDF export filter, and a Preview component, so it has everything I need.
Now, my problem is that I must allow my users to Annull an invoice. So when an invoice was emitted, if there was a problem with it, I cannot just delete it later, I must Annull it (I'm not sure that is how you call it - maybe make it void), but basically the invoice stays the same (in printed form) EXCEPT we must write/draw diagonally on top of the entire invoice one word: ANNULLED with RED color.
That means I will make a new report for this case (annulled invoices) and use this one whenever the user wants to print an annulled invoice
So now in Fortes Report there is an RLAngleLabel component that allows me (in theory) to do just that: draw/write the word ANNULLED on the report. But my problem is that I add the label just fine in the btDetail RLBand, only I just can't see it in Preview, and I have no idea what I am doing wrong. If it's not visible in designtime preview, I assume it wont be visible in runtime neither.
Should I place it in a specific way? Should I add it at runtime somehow? I cant seem to be able to access the report's Canvas so I could draw it in some event...
Does anyone have any experience with what I am describing?
In order to reproduce my problem, just add a RLReport control on your form, add bands to it (Titleband, ColumnHeaderBand, DetailBand), and on a detailBand (DetailGridBand)place an AngleLabel, then right click on the report and choose Preview...
If I place the AngleLabel on the TitleBand or on ColumnHeaderBand, then it shows in preview, except that I need to place this Angled label ON TOP of the contents of the invoice, not on the header info.
In the past I used a BMP image as big as the invoice (in order to have it transparent so I would see the contents beneath it), but that made my exported PDF report 5MB in size, and that is a little too much (PNG was not working correctly - I think it would not display it transparent or something like that, so I was stuck to using BMP).
Is there any way of achieving what I want (described above)?
For whoever encounters this dilema, I reached the conclusion that I should still go with displaying an image containing the desired text as background and setting the bands to Transparent.
The angleLabel approach seems to be unknown, so I dropped it.
I use this time a PNG file that is about 30-40 KB in size and that does not bother me to have it added to the size of the final PDF.
A lot better than the previous BMP image I used before (that increased the size of the PDF file with about 5 MB).
The neweest version of RLReports works with PNG images. That saved me
Also if you have any RLDraw objects on your report, you must set it's brush style to bsClear, so it would allow the background to be visible.

iCarousel index number of starting image to display

I am implementing the API, and i am comparatively new when it comes to use API in ios.
I can understand that the sample images are taken in a dictionary and when fetched, it comes arbitrarily, and when the program is runned, the image at index 1 is displayed as the front image.
I want to make any desired image as the front image one.
How do i achieve this?
If you have read the documentation, it says if you want to set the current index (which in turn sets the image first), you will need to set the currentItemIndex.
So, lets say you have 10 images in your iCarousel and want to set the third one as the front image. You might have to have something like:
[self.carousel setCurrentItemIndex:3];
[self.carousel setCurrentItemIndex:3];
setCurrentItemIndex is set the starting value of Cover Flow.

Photoshop Action to insert text with a box around it

I have a 92 page catalogue (one image per page, multiple products per image) and no product codes on the image for each product.
Does anyone know of a photoshop action to allow entry of a stock code (<15chars text), that will create a filled, outline box with the text inside? It will be awful to have to do them by hand - there are hundreds and hundreds of products.
If all images have the same code, you could record the action which basically creates a macro of your activity for a single image. (Look for the record/playback buttons on the actions pane.)
If all the images have different codes, you might be better off writing (or commissioning) a small script to process the images, such as a PHP script with GD or C# and a graphics object; in both cases reading from a file so it applies the correct code to the image. However this method wouldn't give you an Adobe Photoshop document at the end of the day with an editable text box; it would be a flattened image (such as a TIFF) with the product code already rendered as part of the image.

Resources