This script is an update to my Single Image Collage Maker script. After populating the new image with a collage of smaller images a larger central image, with optional border, is painted. The resultant effect is a picture framed by many smaller pictures. You can select the number of collage images and their size along with the size and border on the central image.
 

Here are a few examples. First the frame is fully populated with the collage and the central image has a thick border. The Collage images are at 10% size on all the examples.
 
FramedImages_20140719_180457
 
In this one the central image is smaller so more of the collage shows.
 
FramedImages_20140718_185231
 
The one has an sparsely populated collage frame and a transparent background.
 
FramedImages_20140719_181227
 
This last one is just a more abstract image with a complete Collage Frame and a Border.
 
CollageFramedImages_20140719_193156
 
I started with the Single Image Collage script and added a TrackBar for the central image size.
 

# Central Image Reduction TrackBar
$centralReductionTrackBar = New-Object Windows.Forms.TrackBar
$centralReductionTrackBar.Location = "190,170"
$centralReductionTrackBar.Orientation = "Horizontal"
$centralReductionTrackBar.Width = 295
$centralReductionTrackBar.Height = 40
$centralReductionTrackBar.LargeChange = 20
$centralReductionTrackBar.SmallChange = 1
$centralReductionTrackBar.TickFrequency = 5
$centralReductionTrackBar.TickStyle = "TopLeft"
$centralReductionTrackBar.SetRange(1, 100)
$centralReductionTrackBar.Value = 80
$centralReductionTrackBarValue = 80
$centralReductionTrackBar.add_ValueChanged({
    $centralReductionTrackBarValue = $centralReductionTrackBar.Value
    $centralReductionTrackBarLabel.Text = "Central Image Size ($centralReductionTrackBarValue%)"
    $global:centralReductionPercent = $centralReductionTrackBarValue
})
$mainForm.Controls.add($centralReductionTrackBar)

# Central Image Reduction Label
$centralReductionTrackBarLabel = New-Object System.Windows.Forms.Label 
$centralReductionTrackBarLabel.Location = "15,170"
$centralReductionTrackBarLabel.Size = "180,23"
$centralReductionTrackBarLabel.ForeColor = "MediumBlue"
$centralReductionTrackBarLabel.Text = "Central Image Size ($centralReductionTrackBarValue%)"
$mainForm.Controls.Add($centralReductionTrackBarLabel)

 
I removed the Output Image Size ComboBox since the final image is the same size as the input image. In it’s place I added a ComboBox for the Border Size of the central image.
 

# Border Width ComboBox
$borderComboBox = New-Object System.Windows.Forms.ComboBox
$borderComboBox.Location = "870,30"
$borderComboBox.Size = "30,20"
$borderComboBox.ForeColor = "Indigo"
$borderComboBox.BackColor = "White"
[void]$borderComboBox.items.add("0")
[void]$borderComboBox.items.add("1")
[void]$borderComboBox.items.add("2")
[void]$borderComboBox.items.add("3")
[void]$borderComboBox.items.add("4")
[void]$borderComboBox.items.add("5")
[void]$borderComboBox.items.add("6")  
[void]$borderComboBox.items.add("7")  
[void]$borderComboBox.items.add("8")             
$borderComboBox.SelectedIndex = 2
$mainForm.Controls.Add($borderComboBox)

# Border Width ComboBox Label
$borderComboBoxLabel = New-Object System.Windows.Forms.Label 
$borderComboBoxLabel.Location = "770,30"
$borderComboBoxLabel.Size = "90,23"
$borderComboBoxLabel.ForeColor = "MediumBlue"
$borderComboBoxLabel.Text = "Border Width"
$mainForm.Controls.Add($borderComboBoxLabel)

 
For the central image I define the image size and added the Brush for the Border, if selected.
 

    $image = [System.Drawing.Image]::FromFile($textBoxIn.Text)
    $brush = New-Object System.Drawing.TextureBrush($image, "Tile")
    $brushBlack = New-Object System.Drawing.SolidBrush("Black")
    $global:imageWidth  = $image.Width
    $global:imageHeight = $image.Height

 
After the Collage is created I paint the central image. If a Border is selected then I do a DrawRectangle to draw it. The size of the Rectangle is set to be larger than the central image by the border width. The central image is then centered and drawn.
 

    # Paint central image
    If ([int]$borderWidth -ge 1) {
        $bitmapGraphics.FillRectangle($brushBlack, `
            (([int]$global:imageWidth-($global:imageWidth*$centralReduction))/2)-$borderWidth, `
            (([int]$global:imageHeight-($global:imageHeight*$centralReduction))/2)-$borderWidth, `
            ($global:imagewidth*$centralReduction)+([int]$borderWidth*2), `
            ($global:imageheight*$centralReduction)+([int]$borderWidth*2))
    }
    $pointX = (([int]$global:imageWidth-($global:imageWidth*$centralReduction))/2)
    $pointY = (([int]$global:imageHeight-($global:imageHeight*$centralReduction))/2)
    $height = ([int]$global:imageHeight * $centralReduction)
    $width  = ([int]$global:imageWidth * $centralReduction)
    $bitmapGraphics.DrawImage($imageFile, $pointX, $pointY, $width, $height)

 
CollageFramedImage
 
Download the complete script here – CollageFramedImage.ps1

Advertisements