ZEN Core Image Handling

In this subforum specific Topics concerning ZEN Core, e.g workbenches, are discussed
Post Reply
user-3450
Posts: 6
Joined: Thu Jan 01, 1970 1:00 am

ZEN Core Image Handling

Post by user-3450 »

Dear all!

Is there any documentation or examples on scripring in ZEN Core?

I'm intrested how to handle Zen.Processing.Utilities.Settings.SingleFileExportSetting() to make a script for batch export.
user-4
Posts: 397
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

Hello VictorL,

ZEN blue and ZEN Core share a very similar macro concept. More than 90% of the code basis is the same. They differ mainly in the way the images (results) are addressed. ZEN blue has a Document Collection (many images open at the same time). This concept does not exist in the same way in ZEN Core as ZEN Core is workflow driven. Our long-term goal is to reduce the difference between ZEN blue and ZEN Core gradually.

To get an idea how Export is ‘transferred’ to ZEN Core three macro examples are given:

Code: Select all

#######################################################
## I M A G E   P R O C E S S I N G 
##
## Macro name: ZenCore - Export several images of a folder
## Required files: 4C image1.czi, 4C image2.czi
##
## LOAD IMAGE, ADJUST AND SAVE EXPORT SETTING FOR FIRST IMAGE,
## APPLY SETTING AND EXPORT ALL IMAGES
## 
#######################################################
##
##
## activate IO library
from System.IO import File, Directory, FileInfo   
##
## define path and file type
path = "C:\\OAD\\Input\\CZI Images\\Multichannel"
newPath = "C:\\OAD\\Output\\TIF Images"
## Check, if path exists
if (Directory.Exists(path)== False):
    strMessage = 'Path: ' + path + ' does not exist!\nRestart macro and select an existing path!'
    sys.exit(strMessage)
## Check, if path exists
if (Directory.Exists(newPath)== False):
    strMessage = 'Path: ' + newPath + ' does not exist!\nRestart macro and select an existing path!'
    sys.exit(strMessage)
## get file type
itype = "*.czi" 
## get files
files = Directory.GetFiles(path,itype)
## Check, if image type exists
if files.Length == 0: 
    strMessage = 'Images of type : ' + itype + ' do not exist!\nRestart macro and select an existing image type!'
    sys.exit(strMessage)
##
## loop over all CZI images in the folder
for i in range(0,files.Length): 
    file = files[i] 
    fileInfo = FileInfo(file) 
    PathAndFile = path + "\\" + fileInfo.Name
    image = Zen.Application.LoadImage(PathAndFile,False) 
    ## do export setup for first image
    if i == 0:
        Zen.Application.ActiveDocument = image
        expset = Zen.Processing.Utilities.InitializeSettingForExportSingleFile(image)
        ## save settings in a file
        wFile = open("C:\\OAD\\Input\\Export Settings\\MyExportSetting.txt",'w')
        wFile.write(expset)
        wFile.close()
    ## extract file  prefix    
    fileNameWE = image.Name.Substring(0,image.Name.Length-4)
    ## apply setting with prefix of active image and path from macro (not taken from setting or initialize dialog)
    Zen.Processing.Utilities.ExportSingleFile(image,expset,fileNameWE,newPath)
    ## Close image (otherwise it cannot be deleted in explorer)
    image.Close()
##
#######################################################

Code: Select all

#######################################################
## I M A G E   P R O C E S S I N G 
##
## Macro name: ZenCore - Create MyExportSetting
##
## ENTER FOLDER FOR EXPORT SETTING, LOAD IMAGE, 
## ADJUST EXPORT SETTING IN EXPORT DIALOG, SAVE EXPORT SETTING
##
## Note: The fixed name: MyExportSetting.txt will be used for user export setting!
#######################################################
##
##
## activate IO library
from System.IO import File, Directory, FileInfo
##
## create setup dialog
window = ZenWindow()
window.AddFolderBrowser('expsetfolder','Export setting folder','C:\OAD\Input\Export Settings')
## do setup
result=window.Show()
## check, if Cancel button was clicked
if result.HasCanceled == True:
    sys.exit('Macro aborted with Cancel!')
##
## get string name of source/destination folder
path = str(result.GetValue('expsetfolder'))
##
## Check, if path exists
if (Directory.Exists(path)== False):
    strMessage = 'Path: ' + path + ' does not exist!\nRestart macro and select an existing path!'
    sys.exit(strMessage)
##
## define full path for export setting
expsetFullpath = str(result.GetValue('expsetfolder')) + '\\' + 'MyExportSetting.txt'
##
## load image
Zen.Application.Pause('Load an image to adjust export settings')
image = Zen.Application.LoadImage()
Zen.Application.ActiveDocument = image
## define export setting
expset = Zen.Processing.Utilities.InitializeSettingForExportSingleFile(image)
## save settings in a file
wFile = open(expsetFullpath,'w')
wFile.write(expset)
wFile.close()
## Close image (otherwise it cannot be deleted in explorer)
image.Close()
##
text = 'MyExportSetting.txt is saved in:\n' + path
Zen.Application.Pause(text)
##
#######################################################

Code: Select all

#######################################################
## I M A G E   P R O C E S S I N G 
##
## Macro name: ZENCore - Export several with user setting
## Required files: 4C image1.czi, 4C image2.czi
## Required files: UserExportSetting.txt in C:\OAD\Input\Export Settings
##
## LOAD USER SETTING, APPLY SETTING AND EXPORT ALL IMAGES AS TIFF IMAGES 
## WITHOUT DISPLAY THE IMAGES IN IMAGES AND DOCUMENTS
## 
#######################################################
##
##
## activate IO library
from System.IO import File, Directory, FileInfo   
##
## define path
path = "C:\\OAD\\Input\\CZI Images\\Multichannel"
## Check, if path exists
if (Directory.Exists(path)== False):
    strMessage = 'Path: ' + path + ' does not exist!\nRestart macro and select an existing path!'
    sys.exit(strMessage)
## get file type
itype = "*.czi" 
## get files
files = Directory.GetFiles(path,itype)
## Check, if image type exists
if files.Length == 0: 
    strMessage = 'Images of type : ' + itype + ' do not exist!\nRestart macro and select an existing image type!'
    sys.exit(strMessage)
##
## loop over all CZI images in the folder with already saved setting of a previous session
## without defining a setting for the first image
## images will be exported as TIFF images
for i in range(0,files.Length): 
    file = files[i] 
    fileInfo = FileInfo(file) 
    PathAndFile = path + "\\" + fileInfo.Name
    ## load image without display the image in center screen area
    image = Zen.Application.LoadImage(PathAndFile,False) 
    Zen.Application.ActiveDocument = image
    ## get user setting
    rFile = open("C:\\OAD\\Input\\Export Settings\\MyExportSetting.txt",'r')
    expset = rFile.read()
    ## extract file  prefix    
    fileNameWE = image.Name.Substring(0,image.Name.Length-4)
    ## apply user setting with prefix to all other images in the folder and export image
    ## prefix is taken of active image (not from usersetting)
    Zen.Processing.Utilities.ExportSingleFile(image,expset,fileNameWE)
    image.Close
    rFile.close
##
#######################################################
user-3450
Posts: 6
Joined: Thu Jan 01, 1970 1:00 am

My thanks!

Post by user-3450 »

Great! Thanks for this helpful info!
The jacketer
Posts: 1
Joined: Wed Dec 13, 2023 9:14 am

Men's Real Shearling Coat

Post by The jacketer »

Experience the pinnacle of tough sophistication by combining warmth and style in a <ahref="https://www.theleatherjacketer.com/mens-shearling-jacket/">Mens Leather Shearling</a>. This authentic shearling coat is made for the daring and has a classic look. This statement garment that promises both fashion and practicality will elevate your winter wardrobe.
M Ahmad
Posts: 1
Joined: Sat Mar 23, 2024 12:21 pm

Re: ZEN Core Image Handling

Post by M Ahmad »

When it comes to men's real shearling coats, quality is paramount. Look for coats crafted from genuine shearling, as it offers unmatched warmth and durability. Shearling coats are a timeless investment piece that exudes sophistication and style.

When purchasing a men's shearling coat, consider factors such as the cut, fit, and color to ensure it complements your personal style beautystylenet.com, and body shape. Opt for classic silhouettes like bomber jackets or trench coats for a versatile addition to your wardrobe that can be dressed up or down.

Keep an eye out for reputable brands known for their craftsmanship and attention to detail. While shearling coats can be a significant investment, they often last a lifetime when cared for properly.

Lastly, be mindful of the maintenance requirements of shearling coats. Proper storage and occasional professional cleaning are essential to preserve the luxurious look and feel of your coat for years to come.

Investing in a men's real shearling coat is not just about staying warm; it's about making a statement with a timeless piece that exudes quality and sophistication.
Post Reply