Skip to main content

system.kanoa.cmms.processImage(filePath, procedureStepCheckId, chkImageId, imageName, imageType, imageDescription, userId)

Processes a raw image file from disk for storage in the CMMS. It converts the source file to JPG format, generates a thumbnail from it, and persists both the full image and the thumbnail to the database. Pass chkImageId as None to create a brand-new image record, or supply an existing chkImageId to reprocess/replace an image already on file. The function can optionally be linked to a procedure step check via procedureStepCheckId, and requires an imageName, imageType, imageDescription, and the userId of the user performing the action for auditing purposes.


Parameters

filePath String: Path to the image file
procedureStepCheckId Integer: Id of check item. Can be None
chkImageId Integer: Id of image. Can be None for a new image
imageName String: Name for the image
imageType String: Type of the image. Can be user defined.
imageDescription String: Description of the image
userId Integer:Id of the user executing the function


Returns

imageId Integer
message String None if success


Example

# Upload a new photo captured for a procedure step check, converting it to JPG and generating a thumbnail in the same call.

filePath = "C:\\Temp\\kanoa\\uploads\\weldInspection_0472.png"
procedureStepCheckId = 9821
chkImageId = None # None means create a new image record
imageName = "Weld Inspection - Panel 4"
imageType = "Inspection Photo"
imageDescription = "Visual inspection of weld seam prior to sign-off"
userId = system.kanoa.security.getIDPUserId({'userName': 'SYSTEM'})

imageId, msg = system.kanoa.cmms.processImage(filePath, procedureStepCheckId, chkImageId, imageName, imageType, imageDescription, userId)
print imageId, msg