<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>how-to | MaxVergelli.com</title>
	<atom:link href="https://www.maxvergelli.com/tag/how-to/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.maxvergelli.com</link>
	<description>sourcecode repository</description>
	<lastBuildDate>Fri, 17 Apr 2020 18:11:05 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://i2.wp.com/www.maxvergelli.com/wp-content/uploads/2020/04/wp-1586823685141.png?fit=32%2C32&#038;ssl=1</url>
	<title>how-to | MaxVergelli.com</title>
	<link>https://www.maxvergelli.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">34603511</site>	<item>
		<title>How to convert HDR10+ videos to SDR (for non-HDR devices)</title>
		<link>https://www.maxvergelli.com/how-to-convert-hdr10-videos-to-sdr-for-non-hdr-devices/</link>
					<comments>https://www.maxvergelli.com/how-to-convert-hdr10-videos-to-sdr-for-non-hdr-devices/#comments</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Fri, 17 Apr 2020 13:02:00 +0000</pubDate>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Video Editing]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[device]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[format-conversion]]></category>
		<category><![CDATA[galaxy-s10]]></category>
		<category><![CDATA[hdr]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[mp4]]></category>
		<category><![CDATA[sdr]]></category>
		<category><![CDATA[smartphone]]></category>
		<category><![CDATA[standard-dynamic-range]]></category>
		<category><![CDATA[tv]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[video-conversion]]></category>
		<category><![CDATA[video-editing]]></category>
		<guid isPermaLink="false">https://www.maxvergelli.com/?p=251</guid>

					<description><![CDATA[<p>How to convert HDR10+ videos to SDR, so can be viewed on non-HDR devices with brightful and not washed-out colors</p>
<p>The post <a href="https://www.maxvergelli.com/how-to-convert-hdr10-videos-to-sdr-for-non-hdr-devices/">How to convert HDR10+ videos to SDR (for non-HDR devices)</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>New smartphones like <em>Samsung Galaxy S10</em> and <em>S10+</em> can record videos in HDR10+, a new standard in HDR, which redefine the concept of Higher Dynamic Range (<em><strong>HDR</strong></em>). <a href="https://www.youtube.com/watch?v=aws42wl7cck" target="_blank" aria-label="Watch this video (opens in a new tab)" rel="noreferrer noopener" class="aioseop-link">Watch this video</a> to learn how to record videos in HDR10+, otherwise, continue reading the post&#8230;</p>



<h4><strong>Differences with HDR and how HDR10+ works</strong>&#8230;</h4>



<p>The standard HDR technology adds up the static metadata to the content (*.MP4 video). This will mean that the parameters are applied at the beginning itself and continue throughout. This causes the bright scenes in a movie look too bright and lose detail, while the dark scenes would continue to look dim. In HDR10+ the brightness boundaries of the video clip is configured and changed in a frame by frame manner, the full-color range is added to every scene dynamically no matter whether it contains only dark or only light scenes. </p>



<p>In other words, HDR10+ ensures that you will end up getting the best details in your videos and images.</p>



<h3><strong>How an HDR10+ video is viewed on supported and non-HDR devices</strong></h3>



<p>There is a problem, when viewing an HDR10+ video on a device that does not support the HDR10+ standard, the video will be displayed as in the following image on the left (with washed-out colors), while on a Galaxy S10 smartphone or TV that supports HDR10+ you will see it as in the image on the right</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="800" height="226" src="https://i0.wp.com/www.maxvergelli.com/wp-content/uploads/2020/04/hdr-to-sdr.jpg?resize=800%2C226&#038;ssl=1" alt="" class="wp-image-252" srcset="https://i0.wp.com/www.maxvergelli.com/wp-content/uploads/2020/04/hdr-to-sdr.jpg?w=800&amp;ssl=1 800w, https://i0.wp.com/www.maxvergelli.com/wp-content/uploads/2020/04/hdr-to-sdr.jpg?resize=300%2C85&amp;ssl=1 300w, https://i0.wp.com/www.maxvergelli.com/wp-content/uploads/2020/04/hdr-to-sdr.jpg?resize=768%2C217&amp;ssl=1 768w" sizes="(max-width: 800px) 100vw, 800px" data-recalc-dims="1" /></figure>



<p>So, to view an HDR10+ video on an unsupported device, <strong>we must first convert it to a video in SDR (standard dynamic range)</strong> which however must retains the same depth and intensity of colors, without washed-out colors, as the original HDR10+ video.</p>



<h2><strong>How to convert HDR10+ video to SDR on PC</strong></h2>



<p>To make the video conversion from HDR10+ to SDR is very simple on a Samsung Galaxy S10 smartphone, but <strong>in this article I will explain how to convert it on PC</strong> (otherwise, if you want to know how to convert it on Galaxy S10, <a aria-label="read this from Samsung (opens in a new tab)" href="https://www.samsung.com/us/support/answer/ANS00086003/" target="_blank" rel="noreferrer noopener" class="aioseop-link">read this from Samsung</a>).</p>



<p>First of all, you need the <strong>ffmpeg</strong> software, a free command-line tool that converts audio or video formats; from this link <a href="http://ffmpeg.org/download.html" target="_blank" aria-label=" (opens in a new tab)" rel="noreferrer noopener" class="aioseop-link">http://ffmpeg.org/download.html</a> look for &#8220;Get packages &amp; executable files&#8221;, and download the compiled version for your OS (Linux, Windows or Mac).</p>



<h4><strong>Step 1</strong> : <strong>Extract FFMPEG to a folder</strong></h4>



<p>Extract the contents of the zip file to a new folder in &#8220;C:\ffmpeg\&#8221; (this is a windows path, but you can change it at your convenience).</p>



<h4><strong>Step 2</strong> : <strong>Create a Batch file and copy your HDR10+ video to convert</strong></h4>



<p>Create a new file named &#8220;convert.bat&#8221; in &#8220;C:\ffmpeg\bin&#8221; with the following code</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;Shell&quot;,&quot;modeName&quot;:&quot;shell&quot;}">C:\ffmpeg\bin\ffmpeg.exe -i video-input.mp4 -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p -c:v libx265 -crf 22 -preset medium -tune fastdecode video-output.mp4</pre></div>



<p>Then, copy your HDR10+ video in &#8220;C:\ffmpeg\bin&#8221; and rename it in &#8220;video-input.mp4&#8221;</p>



<h4><strong>Step 3</strong> : <strong>Open a command prompt and execute the batch</strong></h4>



<p>Now, press <strong>Windows</strong> button+<strong>R</strong> to <strong>open</strong> the “Run” box. Type “<strong>cmd</strong>” and click “OK” to open a regular Command Prompt. Finally, type &#8220;C:\ffmpeg\bin\convert.bat&#8221; to start the conversion from HDR10+ video to a new SDR video named &#8220;video-output.mp4&#8221;.</p>



<h4><strong>Conversion completed!</strong></h4>



<p>At the end of the conversion, you will find the new converted file in the &#8220;C:\ffmpeg\bin\&#8221; folder. </p>



<p>The new SDR file &#8220;video-output.mp4&#8221; <strong>can be viewed on all non-HDR devices, but with the same brightful colors</strong> as the original HDR10+ video.</p>



<p>Have fun converting your movies! 😀</p><p>The post <a href="https://www.maxvergelli.com/how-to-convert-hdr10-videos-to-sdr-for-non-hdr-devices/">How to convert HDR10+ videos to SDR (for non-HDR devices)</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/how-to-convert-hdr10-videos-to-sdr-for-non-hdr-devices/feed/</wfw:commentRss>
			<slash:comments>14</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">251</post-id>	</item>
		<item>
		<title>Resize an image with the same aspect ratio or with custom and crop sizes in PHP</title>
		<link>https://www.maxvergelli.com/how-to-resize-an-image-with-the-same-aspect-ratio-or-with-custom-and-crop-sizes-in-php/</link>
					<comments>https://www.maxvergelli.com/how-to-resize-an-image-with-the-same-aspect-ratio-or-with-custom-and-crop-sizes-in-php/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Tue, 07 Apr 2020 14:33:47 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[aspect-ratio]]></category>
		<category><![CDATA[crop]]></category>
		<category><![CDATA[custom-dimensions]]></category>
		<category><![CDATA[dimensions]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php-class]]></category>
		<category><![CDATA[php-function]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[resize-image]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=193</guid>

					<description><![CDATA[<p>In this article, I will explain how to resize an image in two different ways resizing with custom dimensions keeping the same proportions/aspect ratio Method 1: Resizing with custom dimensions The most practical method in PHP to resize an image &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/how-to-resize-an-image-with-the-same-aspect-ratio-or-with-custom-and-crop-sizes-in-php/" aria-label="Resize an image with the same aspect ratio or with custom and crop sizes in PHP">Read More</a></p>
<p>The post <a href="https://www.maxvergelli.com/how-to-resize-an-image-with-the-same-aspect-ratio-or-with-custom-and-crop-sizes-in-php/">Resize an image with the same aspect ratio or with custom and crop sizes in PHP</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>In this article, I will explain how to resize an image in two different ways</p>



<ul><li>resizing with custom dimensions</li><li>keeping the same proportions/aspect ratio</li></ul>



<p><strong>Method 1: Resizing with custom dimensions</strong><br><br>The most practical method in PHP to resize an image with custom and crop sizes (without keeping the original proportions/aspect ratio) is implementing the following function: </p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">function resize_image($file, $w, $h, $crop=false) {
    list($width, $height) = getimagesize($file);
    $r = $width / $height;
    if ($crop) {
        if ($width &gt; $height) {
            $width = ceil($width-($width*abs($r-$w/$h)));
        } else {
            $height = ceil($height-($height*abs($r-$w/$h)));
        }
        $newwidth = $w;
        $newheight = $h;
    } else {
        if ($w/$h &gt; $r) {
            $newwidth = $h*$r;
            $newheight = $h;
        } else {
            $newheight = $w/$r;
            $newwidth = $w;
        }
    }
    $src = imagecreatefromjpeg($file);
    $dst = imagecreatetruecolor($newwidth, $newheight);
    imagecopyresampled($dst, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

    return $dst;
}</pre></div>



<p>if you set the $crop value on <em>true</em>, the image will be cropped starting from the center, otherwise it will be resized with the new values of width and height</p>



<p><strong>Method 2: keeping the aspect ratio</strong></p>



<p>The second method implements the SimpleImage class by Simon Jarvis, save in a new *.php file the following class and <em>require_once</em> it in your current script</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">/*
* File: SimpleImage.php
* Author: Simon Jarvis
* Copyright: 2006 Simon Jarvis
* Date: 08/11/06
* Link: http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
* http://www.gnu.org/licenses/gpl.html
*
*/

class SimpleImage {

   var $image;
   var $image_type;

   function load($filename) {

      $image_info = getimagesize($filename);
      $this-&gt;image_type = $image_info[2];
      if( $this-&gt;image_type == IMAGETYPE_JPEG ) {

         $this-&gt;image = imagecreatefromjpeg($filename);
      } elseif( $this-&gt;image_type == IMAGETYPE_GIF ) {

         $this-&gt;image = imagecreatefromgif($filename);
      } elseif( $this-&gt;image_type == IMAGETYPE_PNG ) {

         $this-&gt;image = imagecreatefrompng($filename);
      }
   }
   function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) {

      if( $image_type == IMAGETYPE_JPEG ) {
         imagejpeg($this-&gt;image,$filename,$compression);
      } elseif( $image_type == IMAGETYPE_GIF ) {

         imagegif($this-&gt;image,$filename);
      } elseif( $image_type == IMAGETYPE_PNG ) {

         imagepng($this-&gt;image,$filename);
      }
      if( $permissions != null) {

         chmod($filename,$permissions);
      }
   }
   function output($image_type=IMAGETYPE_JPEG) {

      if( $image_type == IMAGETYPE_JPEG ) {
         imagejpeg($this-&gt;image);
      } elseif( $image_type == IMAGETYPE_GIF ) {

         imagegif($this-&gt;image);
      } elseif( $image_type == IMAGETYPE_PNG ) {

         imagepng($this-&gt;image);
      }
   }
   function getWidth() {

      return imagesx($this-&gt;image);
   }
   function getHeight() {

      return imagesy($this-&gt;image);
   }
   function resizeToHeight($height) {

      $ratio = $height / $this-&gt;getHeight();
      $width = $this-&gt;getWidth() * $ratio;
      $this-&gt;resize($width,$height);
   }

   function resizeToWidth($width) {
      $ratio = $width / $this-&gt;getWidth();
      $height = $this-&gt;getheight() * $ratio;
      $this-&gt;resize($width,$height);
   }

   function scale($scale) {
      $width = $this-&gt;getWidth() * $scale/100;
      $height = $this-&gt;getheight() * $scale/100;
      $this-&gt;resize($width,$height);
   }

   function resize($width,$height) {
      $new_image = imagecreatetruecolor($width, $height);
      imagecopyresampled($new_image, $this-&gt;image, 0, 0, 0, 0, $width, $height, $this-&gt;getWidth(), $this-&gt;getHeight());
      $this-&gt;image = $new_image;
   }      

}
</pre></div>



<p>then you can instantiate the above class in the following way in your script, to resize an image keeping the same proportions:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">$filename = 'your filename here!';		

list($width, $height) = getimagesize($filename);
	
$max_width = 1920;
$max_height = 1080;
$new_width = 1280;
$new_height = 720;

if($width &gt;= $height){
  $ratio = $max_width / $width;
  $new_height = $height * $ratio;
} else {
  $ratio = $max_height / $height;
  $new_width = $width * $ratio;
}

$image = new SimpleImage();
$image-&gt;load($filename);
$image-&gt;resize($new_width, $new_height);
$image-&gt;save($filename);
</pre></div><p>The post <a href="https://www.maxvergelli.com/how-to-resize-an-image-with-the-same-aspect-ratio-or-with-custom-and-crop-sizes-in-php/">Resize an image with the same aspect ratio or with custom and crop sizes in PHP</a> first appeared on <a href="https://www.maxvergelli.com">MaxVergelli.com</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/how-to-resize-an-image-with-the-same-aspect-ratio-or-with-custom-and-crop-sizes-in-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">193</post-id>	</item>
	</channel>
</rss>
