示例#1
0
    def _convert_pdf_images(self, pdf_input):
        """Container for pdf->image converstions.

        args:
            pdf_input(str): path to pdf file

        """
        pdf_convertor = ImageMagickConverter(image_type="pdf")
        if self.tn:

            image_output = self._get_output_path("_TN.jpg")
            if not os.path.exists(image_output):
                print "Creating TN for {0}".format(os.path.basename(pdf_input))
                pdf_convertor.convert_pdf_tn(pdf_input, image_output)
                self.derive_results.append(pdf_convertor.return_code)

        if self.preview:

            image_output = self._get_output_path("_PREVIEW.jpg")
            if not os.path.exists(image_output):
                print "Creating PREVIEW for {0}".format(os.path.basename(pdf_input))
                pdf_convertor.convert_pdf_preview(pdf_input, image_output)
                self.derive_results.append(pdf_convertor.return_code)
示例#2
0
    def _convert_images(self, image_input):
        """Container for image->image conversions.

        Positional arguments:
        image_input (str) -- this should simply be the filename (not full path)
        """
        image_convertor = ImageMagickConverter()

        if self.tn:
            image_output = self._get_output_path("_TN.jpg")
            if not os.path.exists(image_output):
                image_convertor.convert_thumbnail(image_input, image_output)
                self.derive_results.append(image_convertor.return_code)

        if self.jp2:
            image_output = self._get_output_path("_JP2.jp2")
            if not os.path.exists(image_output):
                image_convertor.convert_jp2(image_input, image_output)
                self.derive_results.append(image_convertor.return_code)

        if self.jpeg_low_quality:

            image_output = self._get_output_path("_JPG_LOW.jpg")
            if not os.path.exists(image_output):
                image_convertor.convert_jpeg_low(image_input, image_output)
                self.derive_results.append(image_convertor.return_code)

        if self.jpeg_high_quality:

            image_output = self._get_output_path("_JPG_HIGH.jpg")
            if not os.path.exists(image_output):
                image_convertor.convert_jpeg_high(image_input, image_output)
                self.derive_results.append(image_convertor.return_code)

        if self.preview:
            image_output = self._get_output_path("_PREVIEW.jpg")
            if not os.path.exists(image_output):
                image_convertor.convert_preview(image_input, image_output)
                self.derive_results.append(image_convertor.return_code)