# Create thumbnail with GraphicsMagick

**URL:** <https://the.fmsoup.org/t/create-thumbnail-with-graphicsmagick/3506>\
**Category:** MBS Plugins\
**Tags:** plugin, mbs\
**Created:** [April 16, 2023, 8:08am UTC](https://the.fmsoup.org/t/create-thumbnail-with-graphicsmagick/3506 "2023-04-16T08:08:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MonkeybreadSoftware](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/monkeybreadsoftware/32/361_2.png) [@MonkeybreadSoftware](https://the.fmsoup.org/u/MonkeybreadSoftware)\
**Post date:** [April 16, 2023, 8:08am UTC](https://the.fmsoup.org/t/create-thumbnail-with-graphicsmagick/3506/1 "2023-04-16T08:08:44Z")

</div>

Here is a snippet we showed on the [FMTraining](https://fmtraining.tv/) live stream yesterday and it may be interesting for everyone here:

```auto
Set Variable [$image ; Value: MBS( "GMImage.NewFromContainer"; $input)] 
If [MBS("IsError") = 0] 
	# limit size to maximum 1000 pixels in width
	Set Variable [$scale ; Value: MBS("GMImage.Scale";$Image; "1000>")] 
	# remove metadata
	Set Variable [$r ; Value: MBS( "GMImage.SetProfile"; $image; "IPTC"; "" )] 
	Set Variable [$r ; Value: MBS( "GMImage.SetProfile"; $image; "EXIF"; "" )] 
	Set Variable [$r ; Value: MBS( "GMImage.SetProfile"; $image; "XMP"; "" )] 
	# save
	Set Variable [$NewImage ; Value: MBS("GMImage.WriteToJPEGContainer"; $Image)] 
	If [MBS("IsError") = 0] 
		Set Field [Get Preview::Preview ; $NewImage] 
		Set Field [Get Preview::Made using ; "GraphicsMagick"] 
		Set Variable [$r ; Value: MBS("GMimage.Release";$Image)] 
		Exit Script [Text Result:] 
	End If
	Set Variable [$r ; Value: MBS("GMimage.Release";$Image)] 
End If

```

As you see we load an image from a container field or a variable with a container value. Then we scale it to a maximum width of 1000 pixels. We remvoe metadata and then write out a JPEG image.

We could add a call to [GMImage.SetDensity](https://www.mbsplugins.eu/GMImageSetDensity.shtml) in order to change resolution metadata if needed.
