How can I export an image with Script-Fu to the folder with the GIMP file? - directory

My Script works, but the exported file will be saved in my user folder. How can I automatically export the .png to the folder with my GIMP file?
(define (script-fu-biz-scale Image Layer Drawable)
(gimp-layer-sca080le Layer 1920 1 TRUE)
(file-png-save 1 Image Drawable "BizScale.png" "BizScale.png" 0 0 0 0 0 0 0)
)
(script-fu-register
"script-fu-biz-scale"
"<Image>/Filters/BizScale"
"Scaling images automaticly"
"Lukas"
"Lukas"
"12.12.2022"
"RGB*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Layer" 0
SF-DRAWABLE "Drawable" 0
)

You could use gimp-image-get-filename to get the filepath of your original image, strip off the filename and add the new file name.

Related

Copy all files matching pattern from dir and subdirs into a single dir

I have multiple folders into the path: "/home/user/IAT/main/assets/"
Each folder have the following structure: "~/assets /lroot/images/batch0001/samples/"
AllFolders
lroot
images
batch0001
samples
figure_12.png
figure_17.png
...
thumbnails
dataframes
all_g2
images
batch0001
samples
figure_y32.png
figure_x79.png
...
thumbnails
dataframes
before_g1
images
batch0001
samples
figure_2.jpg
figure_17.jpg
...
thumbnails
dataframes
I have a *.txt with name of some images (without extension) into this folders.
for example: figure_12, figure_17, figure_x79, figure_2 and figure_17
I would to copy this images in folder samples referenced in *.txt to another folder in Desktop.
How could I to do that in R?
Thank's all
I recently figured out how to do this. Below I use the magick package to create a couple of test images.
library(magick)
image1 = image_blank(600,600,col="darkred")
image_write(image1, path="./tst1/image1.png")
image2 = image_blank(600,600,col="darkblue")
image_write(image2, path="./tst1/image2.png")
images=c("image1.png","image2.png")
pathOld = "./tst1/"
pathNew = "./tst1/tst2/"
for (i in 1:length(images)) {
fileOld = paste0(pathOld,images[i])
fileNew = paste0(pathNew,images[i])
file.copy(fileOld,fileNew)
print(c(fileOld,fileNew,i))
}

Assistance in understanding sqr logic

Hello, I am new to learning how to develop sqr programs within PeopleSoft. I've been going through some programs we are utilizing and wanted to see if someone could help provide clarification with what the below snippet of code is doing in this While loop.
if $path != ''
let $Archive_File = $path || 'ARCHIVE\' || $filename || $Curr_Date || '.dat'
open $Out_File as 1 for-reading record=450:vary status=#fileread
open $Archive_File as 2 for-writing record=450:vary status=#filewrite
While 1
if #END-FILE
break
else
read 1 into $Current_Line:999
write 2 from $Current_Line
end-if
End-While
close 1
close 2
end-if
I'm trying to understand if the WHILE statement is evaluating the "$Out_File as 1" as the logical expression, or is 1 being evaluated as the value of the variable #END-FILE (As I understand this variable is set to either 0 or 1).
Its a true loop, it will go there until reach a BREAK.
In this case if #END-FILE is true, the loop will break.
In addition to the file name, the open command takes a number as a parameter which it uses as a handler for the file. In your example, two files are being opened.
The WHILE 1 statement doesn't have anything to do with file 1. Here 1 means true, instead of 0 for false. So 1 is always true, creating an endless loop unless something within the loop breaks out if it, which in this case is the BREAK command.
The #END-FILE variable contains FALSE when the file cursor is not at EOF, and a TRUE when the the file cursor is at EOF.
An alternative, which uses less lines of code and is easier to understand might look like this:
if $path != ''
let $Archive_File = $path || 'ARCHIVE\' || $filename || $Curr_Date || '.dat'
open $Out_File as 1 for-reading record=450:vary status=#fileread
open $Archive_File as 2 for-writing record=450:vary status=#filewrite
While Not #END-FILE
read 1 into $Current_Line:999
write 2 from $Current_Line
End-While
close 1
close 2
end-if

Symfony - Overwrite entity_widget

I have table with categories and instead of having name column for every language, I'm storing translations so it looks like this:
1 2 category.macbook_12.name img-12 category.macbook_12.title category.macbook_12.title macbook-12.jpg 0
2 category.macbook.name macbook category.macbook.title category.macbook.description macbook.jpg 0
3 2 category.macbook_air.name macbook-air category.macbook_air.title category.macbook_air.description macbook-air.jpg 0
4 3 category.macbook_air_11.name macbook-air-11 category.macbook_air_11.title category.macbook_air_11.description macbook-air-11.jpg 0
5 3 category.macbook_air_13.name macbook-air-13 category.macbook_air_13.title category.macbook_air_13.description macbook-air-13.jpg 0
6 2 category.macbook_pro.name macbook-pro category.macbook_pro.title category.macbook_pro.description macbook-pro.jpg 0
7 6 category.macbook_pro_13.name macbook-pro-13 category.macbook_pro_13.title category.macbook_pro_13.description macbook-pro-13.jpg 0
....
I'm trying to create form with entity field. Like this:
->add('categories', EntityType::class, [
'class' => Category::class,
'choice_label' => 'name',
'placeholder' => 'form.product.category.placeholder'
])
It's not translating name categories but without translating them.
I think, I should customise entity_widget and add |trans to it, but I can't find original one so I can edit it, because I'm not sure how to fetch data from entity.
Where can I find original entity_widget?
Or is there another way to force translating?
Thanks
If you want to translate choices in your form, you can set
choice_translation_domain => 'messages'.
Your translations MUST be in directory
the app/Resources/translations directory;
the app/Resources/<bundle_name>/translations directory;
the Resources/translations/ directory inside of any bundle.
via Docs
and stored in file messages.{NEEDED_LANGUAGE}.yml as #DOZ said.
NEEDED_LANGUAGE can be short (en, de, ru, pl) or long (en_US, en_AU, en_GB).
Also you can name your translations as you want, but with NEEDED_LANGUAGE notation. So your category.yml file must be named category.en.yml and must stored in translations directory.
For using translations from your custom file, u must set translation_domain and choice_translation_domain manually on each field or in twig file globaly.
# src/{BUNDLE_NAME}/Resources/translations/messages.en.yml (based on symfony version)
category:
macbook_12.name: "Macbook 12"
macbook_12.title: "Macbook 12` laptop"
macbook.name: "Macbook"
macbook.title: "Macbook laptop"
form.product.category.placeholder: "Awesome macbooks here!"
# ... and yet

Getting internal server error when trying to list top 100 newest files in folder

I have a folder with 114,000 files in it (not under my control) and I want to list only the latest 100 of them that have been modified. So I hobbled together an ASP script from different sources, but it's giving me an internal server error when I run it.
<%
Function SortFiles(files)
ReDim sorted(files.Count - 1)
Dim file, i, j
i = 0
For Each file in files
Set sorted(i) = file
i = i + 1
Next
For i = 0 to files.Count - 2
For j = i + 1 to files.Count - 1
If sorted(i).DateLastModified < sorted(j).DateLastModified Then
Dim tmp
Set tmp = sorted(i)
Set sorted(i) = sorted(j)
Set sorted(j) = tmp
End If
Next
Next
SortFiles = sorted
End Function
dim fileserver,files,file,i
set fileserver=Server.CreateObject("Scripting.FileSystemObject")
set files=fileserver.GetFolder(Server.MapPath(".")).Files
i = 0
For Each file in SortFiles(files)
Response.write(x.Name & "\t" & x.Size & "\n")
i = i + 1
If i > 100 Then
Exit For
End If
Next
set fo=nothing
set files=nothing
%>
The files I want listed just need to have their name and size separated by new lines. I am new to ASP so I'm not sure how to debug this.
Move the code from aspx to aspx.cs (code behind) and you can debug it by adding breakpoint, and F10/F11 to step over/step into. I don't know if you can debug inline code, looks like you can by some SO answer.
At first glance, SortFiles does not return a list of file, so it can not be used in a For Each loop.
For Each file in SortFiles(files) //exception
And what is this for?
SortFiles = sorted
I don't know VB, but you can debug yourself.

How can i replace url from css

I'm trying to combine multiple css files into a single file (from many different folder in my host, and including external css files). I use the following short code:
Declare array:
$styles=array(
array(
'name'=>'style1.css',
'path'=>'http://mydomain.com/css/'
),
array(
'name'=>'camera.css',
'path'=>'http://mydomain.com/js/camera/'
),
array(
'name'=>'style3.css',
'path'=>'http://external.com/assets/css/'
));
Get content and replace url:
foreach ($styles as $style) {
echo preg_replace('/url\(\s*[\'"]?\/?(.+?)[\'"]?\s*\)/i', 'url('.$style['path'].'$1)', file_get_contents($style['path'].$style['name']));
}
After combined into one css file, i have some css background image url as follows:
url(ttp://mydomain.com/css/../image/background.png) //Internal path - Case 1A
url(http://mydomain.com/js/camera/../../image/background.png) //Internal path - Case 1B
url(http://external.com/assets/css/../../image/background.png) //External path - Case 2
Actual, the internal path (Case 1A, 1B) can display the background image (despite the lack of professionalism), but in the external path (Case 2) cannot display the background image, my question is:
How can i replace wrong path with correct path (REPAIR BASE ON CURRENT RESULTS) as:
url(http://mydomain.com/image/background.png) //Correct internal path
url(http://external.com/image/background.png) //Correct external path
(I understand the problem is if find a keyword containing '../' will remove keyword and remove 1 string before the keyword contain '*/', , but I can't figure out how to do this).
Thanks in advance.
(I have tried find out and tried searching for 1 week before ask new question).
additionally replace /up-level-directory/../ with /
that is '/([^\/]+)/../' with / globally
$correct_url = preg_replace('|/\w+/\.\./|', '/', $url);

Resources