Convert color image to grayscale PDF by API through PHP

      For some needs, some time we need to convert color image to grayscale PDF by API through PHP, C# or other programming applications. When you have such needs, maybe you can have a free trial of software VeryPDF Image to PDF Converter Cloud API, by which we can convert color image to grayscale PDF easily. Meanwhile this software also can help you convert multi-page TIFF file to multi-page PDF file, convert scanned image files to searchable PDF files by OCR technologies.

Different with other API, VeryPDF API is cloud based, so you can run the conversion at any place or at any system only there is web net connection available. When you run the conversion, simply open browser then the conversion could be done. And before run the conversion, you’d better get an API code which allows you to use it under more than 20 API applications. Please check more information of this software on homepage, in the following part, I will show you how to convert color image to grayscale PDF from PHP code.

Step 1. Convert color image to grayscale PDF

  • When simply run the conversion within browser, please input URL following the below example.
    http://online.verypdf.com/api/apikey=XXXXXXXXXXXXX&
    app=imageproc&infile=http://online.verypdf.com/examples/
    cloud-api/verypdf.jpg&outfile=out.pdf&-type=grayscale
    By this above URL, we can convert color image to grayscale PDF easily. Now let us check parameters which play important role in the conversion.
    -grayscale: when run the conversion, please add this parameter at the end of the URL. There is also other one URL example for converting color image to black and white PDF file, Color image to Black and white image, please have a check.
  • http://online.verypdf.com/api/apikey=XXXXXXXXXXXXX&app=imageproc&infile=
    http://online.verypdf.com/examples/cloud-api/verypdf.jpg&
    outfile=out.pdf&-monochrome&-type=bilevel

Step 2. Convert color image to grayscale PDF from PHP code.

  • When you need to run the conversion from PHP code, please add the above URL to PHP code that would be OK.
  • Here are some code for your reference:
  • <?php
    //The Code
    /* gets the data from a URL */
    function get_data($url)
    {
        $ch = curl_init();
        $timeout = 5;
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        $data = curl_exec($ch);
        curl_close($ch);
        return $data;
    }

    //The Usage
    $returned_content = get_data('http://online.verypdf.com/api/apikey=XXXXXXXXXXXXX&
    app=imageproc&infile=http://online.verypdf.com/examples/cloud-api/verypdf.jpg&outfile=out.pdf&-type=grayscale
    ');
    echo $returned_content;
    ?>

By the above code, we can convert color image to grayscale PDF easily. Now let us check the conversion effect from the following snapshot. During the using, if you have any question, please contact us as soon as possible.

input image and output PDF

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Random Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!