1
$\begingroup$

There is one auto-adjust item in the right-click menu of image in cell.

And other related items are actual size and magnification.

Can we set some values for the auto-adjust? (the effect like ImageResize[image,100] by hand)

The image was interted/paste in the cell.

enter image description here

$\endgroup$
8
  • $\begingroup$ I guess you might be interested in CellEvaluationFunction. $\endgroup$
    – Silvia
    Commented Jun 13, 2013 at 9:15
  • $\begingroup$ @Silvia I'm not sure if that suit for Image, I'll try that. If somewhere we can edit the value of auto-adjust, that would be the simplest way. $\endgroup$ Commented Jun 13, 2013 at 9:17
  • $\begingroup$ @Silvia fine:) CellPrint[ExpressionCell[Rasterize@x,"Input",CellEvaluationFunction->(ImageCrop@ImagePad[ImageResize[ToExpression[#],100],20]&)]] $\endgroup$ Commented Jun 13, 2013 at 9:33
  • $\begingroup$ hmm.. I didn't see difference between you example and that without the CellEvaluationFunction options. $\endgroup$
    – Silvia
    Commented Jun 13, 2013 at 9:49
  • $\begingroup$ @Silvia Evaluate the output cell will generate the effect, or make it one function,or button,This is one old post might related. mathematica.stackexchange.com/questions/25700/… Yeah, seems I still need one function to call the cell. $\endgroup$ Commented Jun 13, 2013 at 10:08

1 Answer 1

1
$\begingroup$

Based on:

Best is scaling determined by width. For example, fixed width is 1000, then image whose width is less that 1000 will keep the actual size, and image whose width is 1200 will be adjusted to 1000, the ratio width/height is the same to that of the original image.

I believe you may use simply:

$PrePrint = # /. i_Image :> Image[i, ImageSize -> 777] &;

This way images in output are automatically scaled to a fixed width (here 777), and only output is affected. That is, if you define:

img = Import["ExampleData/lena.tif"]

The data assigned to img is unchanged, but the output is displayed at the width specified. (If you copy and paste the output the the fixed size is included in that object.)

$\endgroup$
3
  • $\begingroup$ This works, but it looks only affect on images in output cells, and I'd like it affect image in Input Style cells or Text Style cells. $\endgroup$ Commented Jun 21, 2013 at 1:56
  • $\begingroup$ @HyperGroups I don't know about that. Would it be an acceptable solution to programmatically process the Notebook to set image sizes throughout? I know that's not ideal, but if no one has a better idea... $\endgroup$
    – Mr.Wizard
    Commented Jun 22, 2013 at 23:49
  • $\begingroup$ ok, of course,welcome to add some acceptable solutions. $\endgroup$ Commented Jun 23, 2013 at 1:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.