Crop, not scale, the background image and produce an image instead of a pdf











up vote
2
down vote

favorite












Here is my MWE:



documentclass{standalone}
usepackage{graphicx, lipsum}
usepackage[most]{tcolorbox}

newtcolorbox{myminipage}[3]{
breakable,
blankest,
watermark graphics=#3,
watermark stretch=1,
width=#2,
#1
}

begin{document}

begin{myminipage}{3cm}{example-image}
lipsum[2]
end{myminipage}

end{document}


This is taken from here.



The background image scales. Can it be cropped, instead?



And lastly, will it be possible to produce a jpeg or png directly?










share|improve this question




























    up vote
    2
    down vote

    favorite












    Here is my MWE:



    documentclass{standalone}
    usepackage{graphicx, lipsum}
    usepackage[most]{tcolorbox}

    newtcolorbox{myminipage}[3]{
    breakable,
    blankest,
    watermark graphics=#3,
    watermark stretch=1,
    width=#2,
    #1
    }

    begin{document}

    begin{myminipage}{3cm}{example-image}
    lipsum[2]
    end{myminipage}

    end{document}


    This is taken from here.



    The background image scales. Can it be cropped, instead?



    And lastly, will it be possible to produce a jpeg or png directly?










    share|improve this question


























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      Here is my MWE:



      documentclass{standalone}
      usepackage{graphicx, lipsum}
      usepackage[most]{tcolorbox}

      newtcolorbox{myminipage}[3]{
      breakable,
      blankest,
      watermark graphics=#3,
      watermark stretch=1,
      width=#2,
      #1
      }

      begin{document}

      begin{myminipage}{3cm}{example-image}
      lipsum[2]
      end{myminipage}

      end{document}


      This is taken from here.



      The background image scales. Can it be cropped, instead?



      And lastly, will it be possible to produce a jpeg or png directly?










      share|improve this question















      Here is my MWE:



      documentclass{standalone}
      usepackage{graphicx, lipsum}
      usepackage[most]{tcolorbox}

      newtcolorbox{myminipage}[3]{
      breakable,
      blankest,
      watermark graphics=#3,
      watermark stretch=1,
      width=#2,
      #1
      }

      begin{document}

      begin{myminipage}{3cm}{example-image}
      lipsum[2]
      end{myminipage}

      end{document}


      This is taken from here.



      The background image scales. Can it be cropped, instead?



      And lastly, will it be possible to produce a jpeg or png directly?







      graphics crop export






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 4 at 2:58

























      asked Dec 4 at 1:48









      deshmukh

      1,0361326




      1,0361326






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          Are you looking for the standalone class with the varwidth option?



          documentclass[varwidth]{standalone}
          usepackage{ eso-pic,tikz, lipsum}
          usetikzlibrary{tikzmark}
          linespread{2}
          newcommandBackgroundPic{%
          begin{tikzpicture}[overlay,remember picture]
          node[anchor=north west,inner sep=0pt] at ([yshift=8pt]pic cs:start) {%
          includegraphics[width=textwidth]{example-image}};
          end{tikzpicture}}

          begin{document}
          AddToShipoutPicture*{BackgroundPic}

          tikzmark{start}lipsum[1-1]

          end{document}


          enter image description here



          OLDER VERSIONS: tikzpagenodes allows you to precisely determined the text area.



          documentclass{article}
          usepackage{geometry, eso-pic, tikzpagenodes, lipsum}
          linespread{2}
          newcommandBackgroundPic{%
          begin{tikzpicture}[overlay,remember picture]
          node[anchor=north west,inner sep=0pt] at (current page text area.north west) {
          includegraphics[width=textwidth,height=textheight,%
          ]{example-image}};
          end{tikzpicture}}
          geometry{
          a4paper,
          portrait,
          margin=1in,
          top=.25in,
          bottom=1.75in
          }

          begin{document}
          AddToShipoutPicture*{BackgroundPic}
          thispagestyle{empty}

          lipsum[1-1]

          end{document}


          enter image description here



          Here is something that crops the image against the text...



          documentclass{article}
          usepackage{geometry, eso-pic, tikzpagenodes, lipsum}
          usetikzlibrary{tikzmark}
          linespread{2}
          newcommandBackgroundPic{%
          begin{tikzpicture}[overlay,remember picture]
          path ([yshift=12pt]pic cs:start) coordinate(aux1) ([yshift=-3pt]pic cs:end) coordinate(aux2);
          clip (current page text area.west |-aux1) rectangle
          (current page text area.east |-aux2);
          node[anchor=north west,inner sep=0pt] at (current page text area.north west) {%
          includegraphics[width=textwidth]{example-image}};
          end{tikzpicture}}
          geometry{
          a4paper,
          portrait,
          margin=1in,
          top=.25in,
          bottom=1.75in
          }

          begin{document}
          AddToShipoutPicture*{BackgroundPic}
          thispagestyle{empty}

          tikzmark{start}lipsum[1-1]tikzmark{end}

          end{document}


          enter image description here






          share|improve this answer























          • Thanks. But is not the page much larger than the text needs it to be?
            – deshmukh
            Dec 4 at 2:04










          • Also, I found solution to part of the problem. I will modify the question to reflect it.
            – deshmukh
            Dec 4 at 2:05










          • Yes, I think a tcolorbox is a possible solution to the updated question. Do you actually still have a question? (With tikzmark one could cook up something that is truly on the background and does not influence the text, at least as long as there is no page break. I am also not saying that tikzmark is the only or the "best" possible way.)
            – marmot
            Dec 4 at 2:39










          • Yes. I still have a question. The image is scaling. I wish I could crop it from, say, top left
            – deshmukh
            Dec 4 at 2:57










          • @deshmukh Could you please explain what "crop it from, say, top left " means? Does that mean you want no longer adjust the size of the image but literally crop it?
            – marmot
            Dec 4 at 3:14











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "85"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f463075%2fcrop-not-scale-the-background-image-and-produce-an-image-instead-of-a-pdf%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          2
          down vote



          accepted










          Are you looking for the standalone class with the varwidth option?



          documentclass[varwidth]{standalone}
          usepackage{ eso-pic,tikz, lipsum}
          usetikzlibrary{tikzmark}
          linespread{2}
          newcommandBackgroundPic{%
          begin{tikzpicture}[overlay,remember picture]
          node[anchor=north west,inner sep=0pt] at ([yshift=8pt]pic cs:start) {%
          includegraphics[width=textwidth]{example-image}};
          end{tikzpicture}}

          begin{document}
          AddToShipoutPicture*{BackgroundPic}

          tikzmark{start}lipsum[1-1]

          end{document}


          enter image description here



          OLDER VERSIONS: tikzpagenodes allows you to precisely determined the text area.



          documentclass{article}
          usepackage{geometry, eso-pic, tikzpagenodes, lipsum}
          linespread{2}
          newcommandBackgroundPic{%
          begin{tikzpicture}[overlay,remember picture]
          node[anchor=north west,inner sep=0pt] at (current page text area.north west) {
          includegraphics[width=textwidth,height=textheight,%
          ]{example-image}};
          end{tikzpicture}}
          geometry{
          a4paper,
          portrait,
          margin=1in,
          top=.25in,
          bottom=1.75in
          }

          begin{document}
          AddToShipoutPicture*{BackgroundPic}
          thispagestyle{empty}

          lipsum[1-1]

          end{document}


          enter image description here



          Here is something that crops the image against the text...



          documentclass{article}
          usepackage{geometry, eso-pic, tikzpagenodes, lipsum}
          usetikzlibrary{tikzmark}
          linespread{2}
          newcommandBackgroundPic{%
          begin{tikzpicture}[overlay,remember picture]
          path ([yshift=12pt]pic cs:start) coordinate(aux1) ([yshift=-3pt]pic cs:end) coordinate(aux2);
          clip (current page text area.west |-aux1) rectangle
          (current page text area.east |-aux2);
          node[anchor=north west,inner sep=0pt] at (current page text area.north west) {%
          includegraphics[width=textwidth]{example-image}};
          end{tikzpicture}}
          geometry{
          a4paper,
          portrait,
          margin=1in,
          top=.25in,
          bottom=1.75in
          }

          begin{document}
          AddToShipoutPicture*{BackgroundPic}
          thispagestyle{empty}

          tikzmark{start}lipsum[1-1]tikzmark{end}

          end{document}


          enter image description here






          share|improve this answer























          • Thanks. But is not the page much larger than the text needs it to be?
            – deshmukh
            Dec 4 at 2:04










          • Also, I found solution to part of the problem. I will modify the question to reflect it.
            – deshmukh
            Dec 4 at 2:05










          • Yes, I think a tcolorbox is a possible solution to the updated question. Do you actually still have a question? (With tikzmark one could cook up something that is truly on the background and does not influence the text, at least as long as there is no page break. I am also not saying that tikzmark is the only or the "best" possible way.)
            – marmot
            Dec 4 at 2:39










          • Yes. I still have a question. The image is scaling. I wish I could crop it from, say, top left
            – deshmukh
            Dec 4 at 2:57










          • @deshmukh Could you please explain what "crop it from, say, top left " means? Does that mean you want no longer adjust the size of the image but literally crop it?
            – marmot
            Dec 4 at 3:14















          up vote
          2
          down vote



          accepted










          Are you looking for the standalone class with the varwidth option?



          documentclass[varwidth]{standalone}
          usepackage{ eso-pic,tikz, lipsum}
          usetikzlibrary{tikzmark}
          linespread{2}
          newcommandBackgroundPic{%
          begin{tikzpicture}[overlay,remember picture]
          node[anchor=north west,inner sep=0pt] at ([yshift=8pt]pic cs:start) {%
          includegraphics[width=textwidth]{example-image}};
          end{tikzpicture}}

          begin{document}
          AddToShipoutPicture*{BackgroundPic}

          tikzmark{start}lipsum[1-1]

          end{document}


          enter image description here



          OLDER VERSIONS: tikzpagenodes allows you to precisely determined the text area.



          documentclass{article}
          usepackage{geometry, eso-pic, tikzpagenodes, lipsum}
          linespread{2}
          newcommandBackgroundPic{%
          begin{tikzpicture}[overlay,remember picture]
          node[anchor=north west,inner sep=0pt] at (current page text area.north west) {
          includegraphics[width=textwidth,height=textheight,%
          ]{example-image}};
          end{tikzpicture}}
          geometry{
          a4paper,
          portrait,
          margin=1in,
          top=.25in,
          bottom=1.75in
          }

          begin{document}
          AddToShipoutPicture*{BackgroundPic}
          thispagestyle{empty}

          lipsum[1-1]

          end{document}


          enter image description here



          Here is something that crops the image against the text...



          documentclass{article}
          usepackage{geometry, eso-pic, tikzpagenodes, lipsum}
          usetikzlibrary{tikzmark}
          linespread{2}
          newcommandBackgroundPic{%
          begin{tikzpicture}[overlay,remember picture]
          path ([yshift=12pt]pic cs:start) coordinate(aux1) ([yshift=-3pt]pic cs:end) coordinate(aux2);
          clip (current page text area.west |-aux1) rectangle
          (current page text area.east |-aux2);
          node[anchor=north west,inner sep=0pt] at (current page text area.north west) {%
          includegraphics[width=textwidth]{example-image}};
          end{tikzpicture}}
          geometry{
          a4paper,
          portrait,
          margin=1in,
          top=.25in,
          bottom=1.75in
          }

          begin{document}
          AddToShipoutPicture*{BackgroundPic}
          thispagestyle{empty}

          tikzmark{start}lipsum[1-1]tikzmark{end}

          end{document}


          enter image description here






          share|improve this answer























          • Thanks. But is not the page much larger than the text needs it to be?
            – deshmukh
            Dec 4 at 2:04










          • Also, I found solution to part of the problem. I will modify the question to reflect it.
            – deshmukh
            Dec 4 at 2:05










          • Yes, I think a tcolorbox is a possible solution to the updated question. Do you actually still have a question? (With tikzmark one could cook up something that is truly on the background and does not influence the text, at least as long as there is no page break. I am also not saying that tikzmark is the only or the "best" possible way.)
            – marmot
            Dec 4 at 2:39










          • Yes. I still have a question. The image is scaling. I wish I could crop it from, say, top left
            – deshmukh
            Dec 4 at 2:57










          • @deshmukh Could you please explain what "crop it from, say, top left " means? Does that mean you want no longer adjust the size of the image but literally crop it?
            – marmot
            Dec 4 at 3:14













          up vote
          2
          down vote



          accepted







          up vote
          2
          down vote



          accepted






          Are you looking for the standalone class with the varwidth option?



          documentclass[varwidth]{standalone}
          usepackage{ eso-pic,tikz, lipsum}
          usetikzlibrary{tikzmark}
          linespread{2}
          newcommandBackgroundPic{%
          begin{tikzpicture}[overlay,remember picture]
          node[anchor=north west,inner sep=0pt] at ([yshift=8pt]pic cs:start) {%
          includegraphics[width=textwidth]{example-image}};
          end{tikzpicture}}

          begin{document}
          AddToShipoutPicture*{BackgroundPic}

          tikzmark{start}lipsum[1-1]

          end{document}


          enter image description here



          OLDER VERSIONS: tikzpagenodes allows you to precisely determined the text area.



          documentclass{article}
          usepackage{geometry, eso-pic, tikzpagenodes, lipsum}
          linespread{2}
          newcommandBackgroundPic{%
          begin{tikzpicture}[overlay,remember picture]
          node[anchor=north west,inner sep=0pt] at (current page text area.north west) {
          includegraphics[width=textwidth,height=textheight,%
          ]{example-image}};
          end{tikzpicture}}
          geometry{
          a4paper,
          portrait,
          margin=1in,
          top=.25in,
          bottom=1.75in
          }

          begin{document}
          AddToShipoutPicture*{BackgroundPic}
          thispagestyle{empty}

          lipsum[1-1]

          end{document}


          enter image description here



          Here is something that crops the image against the text...



          documentclass{article}
          usepackage{geometry, eso-pic, tikzpagenodes, lipsum}
          usetikzlibrary{tikzmark}
          linespread{2}
          newcommandBackgroundPic{%
          begin{tikzpicture}[overlay,remember picture]
          path ([yshift=12pt]pic cs:start) coordinate(aux1) ([yshift=-3pt]pic cs:end) coordinate(aux2);
          clip (current page text area.west |-aux1) rectangle
          (current page text area.east |-aux2);
          node[anchor=north west,inner sep=0pt] at (current page text area.north west) {%
          includegraphics[width=textwidth]{example-image}};
          end{tikzpicture}}
          geometry{
          a4paper,
          portrait,
          margin=1in,
          top=.25in,
          bottom=1.75in
          }

          begin{document}
          AddToShipoutPicture*{BackgroundPic}
          thispagestyle{empty}

          tikzmark{start}lipsum[1-1]tikzmark{end}

          end{document}


          enter image description here






          share|improve this answer














          Are you looking for the standalone class with the varwidth option?



          documentclass[varwidth]{standalone}
          usepackage{ eso-pic,tikz, lipsum}
          usetikzlibrary{tikzmark}
          linespread{2}
          newcommandBackgroundPic{%
          begin{tikzpicture}[overlay,remember picture]
          node[anchor=north west,inner sep=0pt] at ([yshift=8pt]pic cs:start) {%
          includegraphics[width=textwidth]{example-image}};
          end{tikzpicture}}

          begin{document}
          AddToShipoutPicture*{BackgroundPic}

          tikzmark{start}lipsum[1-1]

          end{document}


          enter image description here



          OLDER VERSIONS: tikzpagenodes allows you to precisely determined the text area.



          documentclass{article}
          usepackage{geometry, eso-pic, tikzpagenodes, lipsum}
          linespread{2}
          newcommandBackgroundPic{%
          begin{tikzpicture}[overlay,remember picture]
          node[anchor=north west,inner sep=0pt] at (current page text area.north west) {
          includegraphics[width=textwidth,height=textheight,%
          ]{example-image}};
          end{tikzpicture}}
          geometry{
          a4paper,
          portrait,
          margin=1in,
          top=.25in,
          bottom=1.75in
          }

          begin{document}
          AddToShipoutPicture*{BackgroundPic}
          thispagestyle{empty}

          lipsum[1-1]

          end{document}


          enter image description here



          Here is something that crops the image against the text...



          documentclass{article}
          usepackage{geometry, eso-pic, tikzpagenodes, lipsum}
          usetikzlibrary{tikzmark}
          linespread{2}
          newcommandBackgroundPic{%
          begin{tikzpicture}[overlay,remember picture]
          path ([yshift=12pt]pic cs:start) coordinate(aux1) ([yshift=-3pt]pic cs:end) coordinate(aux2);
          clip (current page text area.west |-aux1) rectangle
          (current page text area.east |-aux2);
          node[anchor=north west,inner sep=0pt] at (current page text area.north west) {%
          includegraphics[width=textwidth]{example-image}};
          end{tikzpicture}}
          geometry{
          a4paper,
          portrait,
          margin=1in,
          top=.25in,
          bottom=1.75in
          }

          begin{document}
          AddToShipoutPicture*{BackgroundPic}
          thispagestyle{empty}

          tikzmark{start}lipsum[1-1]tikzmark{end}

          end{document}


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 4 at 15:53

























          answered Dec 4 at 1:55









          marmot

          82.3k492175




          82.3k492175












          • Thanks. But is not the page much larger than the text needs it to be?
            – deshmukh
            Dec 4 at 2:04










          • Also, I found solution to part of the problem. I will modify the question to reflect it.
            – deshmukh
            Dec 4 at 2:05










          • Yes, I think a tcolorbox is a possible solution to the updated question. Do you actually still have a question? (With tikzmark one could cook up something that is truly on the background and does not influence the text, at least as long as there is no page break. I am also not saying that tikzmark is the only or the "best" possible way.)
            – marmot
            Dec 4 at 2:39










          • Yes. I still have a question. The image is scaling. I wish I could crop it from, say, top left
            – deshmukh
            Dec 4 at 2:57










          • @deshmukh Could you please explain what "crop it from, say, top left " means? Does that mean you want no longer adjust the size of the image but literally crop it?
            – marmot
            Dec 4 at 3:14


















          • Thanks. But is not the page much larger than the text needs it to be?
            – deshmukh
            Dec 4 at 2:04










          • Also, I found solution to part of the problem. I will modify the question to reflect it.
            – deshmukh
            Dec 4 at 2:05










          • Yes, I think a tcolorbox is a possible solution to the updated question. Do you actually still have a question? (With tikzmark one could cook up something that is truly on the background and does not influence the text, at least as long as there is no page break. I am also not saying that tikzmark is the only or the "best" possible way.)
            – marmot
            Dec 4 at 2:39










          • Yes. I still have a question. The image is scaling. I wish I could crop it from, say, top left
            – deshmukh
            Dec 4 at 2:57










          • @deshmukh Could you please explain what "crop it from, say, top left " means? Does that mean you want no longer adjust the size of the image but literally crop it?
            – marmot
            Dec 4 at 3:14
















          Thanks. But is not the page much larger than the text needs it to be?
          – deshmukh
          Dec 4 at 2:04




          Thanks. But is not the page much larger than the text needs it to be?
          – deshmukh
          Dec 4 at 2:04












          Also, I found solution to part of the problem. I will modify the question to reflect it.
          – deshmukh
          Dec 4 at 2:05




          Also, I found solution to part of the problem. I will modify the question to reflect it.
          – deshmukh
          Dec 4 at 2:05












          Yes, I think a tcolorbox is a possible solution to the updated question. Do you actually still have a question? (With tikzmark one could cook up something that is truly on the background and does not influence the text, at least as long as there is no page break. I am also not saying that tikzmark is the only or the "best" possible way.)
          – marmot
          Dec 4 at 2:39




          Yes, I think a tcolorbox is a possible solution to the updated question. Do you actually still have a question? (With tikzmark one could cook up something that is truly on the background and does not influence the text, at least as long as there is no page break. I am also not saying that tikzmark is the only or the "best" possible way.)
          – marmot
          Dec 4 at 2:39












          Yes. I still have a question. The image is scaling. I wish I could crop it from, say, top left
          – deshmukh
          Dec 4 at 2:57




          Yes. I still have a question. The image is scaling. I wish I could crop it from, say, top left
          – deshmukh
          Dec 4 at 2:57












          @deshmukh Could you please explain what "crop it from, say, top left " means? Does that mean you want no longer adjust the size of the image but literally crop it?
          – marmot
          Dec 4 at 3:14




          @deshmukh Could you please explain what "crop it from, say, top left " means? Does that mean you want no longer adjust the size of the image but literally crop it?
          – marmot
          Dec 4 at 3:14


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f463075%2fcrop-not-scale-the-background-image-and-produce-an-image-instead-of-a-pdf%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to change which sound is reproduced for terminal bell?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

          Can I use Tabulator js library in my java Spring + Thymeleaf project?