If during indexing you can find the following exception in Crawling.log:

It means that probably some of your media items have a wrong values

Now, you have a difficult choice to make

If you chose to manually solve the problem, you can finish reading here.
Below you can find a ugly Powershell script that will do job automatically and generate at the end report about changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Fix value '123 x 123' in Size field to the proper image size (bytes). | |
# Author: Robert Senktas | |
# | |
$sitecorePath = "master:/sitecore/media library" | |
$processedItems = Get-ChildItem -Path $sitecorePath -Recurse | ForEach-Object { | |
if ( $_.Size -match "x" ) { | |
$mediaItem = New-Object "Sitecore.Data.Items.MediaItem" $_ | |
[Sitecore.Resources.Media.Media] $media = [Sitecore.Resources.Media.MediaManager]::GetMedia($mediaItem); | |
$stream = $media.GetStream() | |
$reportItem = [PSCustomObject]@{ | |
ID = $_.ID | |
Path = $_.Paths.Path | |
Size = $_.Size | |
Length = $stream.Length | |
} | |
$_.Editing.BeginEdit() | |
$_["Size"] = $stream.Length | |
$_.Editing.EndEdit() | |
$_ | Publish-Item -PublishMode SingleItem -Verbose | |
return $reportItem | |
} | |
} | |
# Generate a report | |
Import-Function -Name ConvertTo-Xlsx | |
[byte[]]$outobject = $processedItems | | |
Select-Object -Property ID, Path, Size, Length | | |
ConvertTo-Xlsx | |
Out-Download -Name "report-change-image-size-.xlsx" -InputObject $outobject | |
Below the report.
