Convert ServiceNow Images to either of formats : .jpg, .png, .bmp, .gif, .jpeg, .ico
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2023 09:19 AM
Hello,
I have the below requirement. Please let me know how to fulfill this requirement as I have not worked on this previously before.
"
ServiceNow Image Library must only contain files of following formats: .jpg, .png, .bmp, .gif, .jpeg, .ico
Please convert any other file types (such as .svg) to a supported file format in adequate quality
Go to Catalog Item>>Picture tab>>upload converted images to "icon" and "picture" fields.
Note:1 Make sure the image which is used for that catalog item is converted and uploaded
Note 2: In attached zip file - 80 images in svg format --> desired new format: PNG "
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2023 03:32 AM
you can convert images to different file formats using the GlideScopedEvaluator class and the GlideConvertFile class. Here is an example of how you can convert an image to different file formats using Javascript:
// Get the image file
var image = new GlideSysAttachment();
image.setTableName("incident");
image.setTableSysId("your_incident_sys_id");
image.setFileName("your_image_file_name");
// Define the output file format
var format = ".jpg";
// Convert the image file
var imageConverted = new GlideScopedEvaluator().evaluateString("new GlideConvertFile().convert(\""+image.getUniqueName()+"\", \""+format+"\")");
In the above example, you need to replace the "your_incident_sys_id" with the sys_id of the incident record, and "your_image_file_name" with the file name of the image you want to convert. Also, you can replace ".jpg" with any of the formats you want to convert the image to, such as .png, .bmp, .gif, .jpeg, .ico.
The GlideConvertFile.convert() method will return a GlideSysAttachment object containing the converted image file.
You can also use the GlideSysAttachment.writeToStream() method to write the converted image file to a stream, and then use the stream to download the image file.
Please mark the suggestion as helpful, if you find it useful to you or others who wants to refer similar content.
Please mark the solution as correct, if the answer provided by me has resolved your query.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 01:31 PM
I'm attempting to use this answer to solve a similar problem, but I keep getting a "Illegal access to method setTableName(string) in class com.glide.ui.SysAttachment" error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 10:30 AM
I am seeing the same error. Did you ever figure out a way around it that you might be able to share?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 03:40 AM
I understand that you have a requirement regarding the ServiceNow Image Library and the supported file formats. It seems that you need to ensure that the library contains files only in formats such as .jpg, .png, .bmp, .gif, .jpeg, and .ico. To accomplish this, any other file types, like .svg, need to be converted to a supported format with adequate quality.
In order to convert these images, you can make use of a convenient solution like Converter365 svg converter, a free online converter. It allows you to upload your .svg images and convert them to the desired format, such as PNG. Once the conversion is complete, you can easily upload the converted images to the "icon" and "picture" fields in the Catalog Item>>Picture tab.
By utilizing Converter365, you can ensure that all your images meet the required format specifications. If you have any further questions or need assistance, feel free to ask!
Best regards,